-7

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?

micky
  • 508
  • 5
  • 17

1 Answers1

2

Without actual code:

  1. iterate thorough the array
  2. count the 1s you found
  3. if you found a 0 then start over the count
  4. check after increasing the counter: if the counter reaches 3 then return with true
  5. 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