O(n^2) accepted


#1

Comment body goes here.


#2

Can be done O(N) . Just stretch your imagination a bit.