Easy for this one.

you should change the main loop to

for (int i = 0; i < k; i++)

This is to ensure you search to end of the list


and when flag is 2, also check i<k-2 to ensure it is not out of bound.

if (flag == 2 && i < k - 2)

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-code+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/3729275c-bea8-4273-8c0d-302dd383f28a%40googlegroups.com.

Reply via email to