That is what going through the loop will show.
Norm Radder wrote:Can the code set res . . . after . . .
No, that doesn't count.
Piet Souris wrote:. . . 123 . . .
sai rama krishna wrote:Trying below
i failed one test
can you point me to what mistakes i am doing?
Don't understand that bit, but if you delete those three lines and the break; I would expect your program to give the same results. Of course it is more efficient to exit the loop as soon as possible
sai rama krishna wrote:. . . It worked fine as for expressions not satisfying above if conditions default res false value seems getting returned
Find the old Sun coding conventions and it tells you not to use if‑else to return values. I think you should take the same approach to assignments. You can omit the if‑else altogether like this:-Spacing corrected. Please note where the spaces belong. Of course we already know that code is incorrect.
sai rama krishna wrote:. . .. . .
Well...., sort of......
sai rama krishna wrote:. . . Looks like refactored code 1 is checking whole array which is not right approach for this challenge. . . .
That is how I would read the question.
Piet Souris wrote:Your solution assumes that the sequence 1, 2, 3 should be consecutive. . . .
They aren't random, but in sequence. The sequence may be consecutive or interrupted by other values.
sai rama krishna wrote:. . . If 1, 2, 3 comes in random positions . . .
You don't. It is straightforward enough with a single for‑each loop.
May be I need one other for loop. . . .