Find first index of 1
Trying to outsmart the challenge defeats the purpose
While there is value in learning how to do the bare minimum needed (as you try to detect the number as soon as it is inputted instead of performing a search), there is only so much you can learn by trying to outsmart the challenge and not practice the knowledge this challenge is supposed to help you practice (which in this case is binary search).
Input reading
You can read the input faster using BufferedReader, see this answer's &quot;Reading Data&quot; section for example. You can read a whole line at once and then perform a search.
Binary search
Binary search is a very fast way to find an item in a sorted array where by looking at any element you know if what you're looking for is on the left or right of the current position.
You can perform the search on the string, converting the string to an array of numbers is unnecessary and therefore a waste of time.