Hello Leetcoders,
I recently attempted one Mock test of Facebook at hackerEarth the question asked were of medium to hard level one of them I sharing


As this question seems to be very easy but my solution failed to pass all test cases its complxity was O(N^2).
any better approach If you it please share :)