LeetCode Weekly Contest 15
How about this one:
No one has replied
I did the same solution, without the apply, and making sure we return 0 if there is no 1s in the binary array, and I'm faster than 93% of the solutions:
Rigorously speaking, this is not a 1 pass solution (or at least, it does not solve the follow-up question with stream input) because: in your code block,
you need to access noms[j] where j can be far from i such that num[j] is unavailable with stream input.
In fact, there is a much easier solution which only needs scan the array from head to tail once. Same for the follow-up situations.
Here is the link. There are detailed explanations.
Disabled Categories are greyed out
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.