it's a quite easy problem within n<=1000. But I am wondering can we solve the problem in O(n), I have seen some people mention about it.
Asking for fast solution
it's a quite easy problem within n<=1000. But I am wondering can we solve the problem in O(n), I have seen some people mention about it.