# Completing this problem?

**URL:** <https://discourse.processing.org/t/completing-this-problem/17905>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [February 18, 2020, 3:30am UTC](https://discourse.processing.org/t/completing-this-problem/17905 "2020-02-18T03:30:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kandrews](https://avatars.discourse-cdn.com/v4/letter/k/8dc957/32.png) [@kandrews](https://discourse.processing.org/u/kandrews)\
**Post date:** [February 18, 2020, 3:30am UTC](https://discourse.processing.org/t/completing-this-problem/17905/1 "2020-02-18T03:30:36Z")

</div>

can someone solve this?

Complete the longestRun method as described. Given an array of ints, determine the length of the longest “run” of values contained therein. A “run” is a group of identical values that are adjacent to each other in the array.

**int longestRun(int[] nums)**

Examples:  
longestRun([2,3,4,5,3]) --\> 1  
longestRun([3,1,1,1,1,2,2]) --\> 4  
longestRun([6,5,99,99,3,3]) --\> 2

---

<div class="post-metadata">

**Author:** ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)\
**Post date:** [February 18, 2020, 3:55am UTC](https://discourse.processing.org/t/completing-this-problem/17905/2 "2020-02-18T03:55:02Z")

</div>

Is this a homework question?

---

<div class="post-metadata">

**Author:** ![kandrews](https://avatars.discourse-cdn.com/v4/letter/k/8dc957/32.png) [@kandrews](https://discourse.processing.org/u/kandrews)\
**Post date:** [February 18, 2020, 3:55am UTC](https://discourse.processing.org/t/completing-this-problem/17905/3 "2020-02-18T03:55:38Z")

</div>

yeah, I jus didn’t know how.

---

<div class="post-metadata">

**Author:** ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)\
**Post date:** [February 18, 2020, 4:00am UTC](https://discourse.processing.org/t/completing-this-problem/17905/4 "2020-02-18T04:00:58Z")

</div>

I think there are guidelines in this forum about answering homework questions. Please read: Under Guidelines—Tips for Asking Questions.

---

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [February 18, 2020, 4:03am UTC](https://discourse.processing.org/t/completing-this-problem/17905/5 "2020-02-18T04:03:22Z")

</div>

You should look at each element in the list in order.

Then check if the element continues a run.

If it does, the current run you’re looking at is one longer.

If it doesn’t, you’re starting a new run. What will you need to remember at this point? How will you remember that?

… try working out how you, as a person, would solve this problem. Come up with a list of steps that you can explain. Then write code that does those steps.
