I have array list that each indexes has value either 0 or 1.I want to find that continuously three indexes has the value 1.How do I find it?
Asked
Active
Viewed 128 times
-7
-
2Please show us your attempts thus far so we can determine where you're stuck and what needs explaining. – Jeroen Vannevel Apr 03 '14 at 11:44
-
1iterate over the list and check if the current item and the next two items are == 1. thats a way how you find it, now you have to code it. – kai Apr 03 '14 at 11:44
-
2try writing a bit of code :), then let us know – robermann Apr 03 '14 at 11:45
1 Answers
2
Without actual code:
- iterate thorough the array
- count the 1s you found
- if you found a 0 then start over the count
- check after increasing the counter: if the counter reaches 3 then return with
true
- if you reached the end of the array and no more elements then return with
false
Something like this, I hope I could help.

user2424380
- 1,393
- 3
- 16
- 29