Google asked me a question… I could solve it in O(n²) but not in O(n).
After, with calm, talking about it with a friend who is a professor at university and has a phd in mathematics, he reflected that since my problem only used positive numbers, I could have exploited a certain property and simplify my algorithm.
So in the end, if you're lucky and have faced that particular completely artificial problem before, you can do it.
Otherwise you need some calm to think, and you can't do that while there are two people harassing you because you named your variables with a name they don't like, and a clock is ticking.
In the end you're selecting for "has this person heard of this problem or a similar one before" and not "can this person think".