Any insights?
My solution link: https://ide.codingblocks.com/s/72847
your logic will fail.
your code complexity=O(n^2) i.e. one for loop O(n)* max_element function O(n)
and n is 10^5 in question i.e. O(n^2)=10^10 which is greater than max fixed limit O(10^8).
So your code will give TLE .
Try to solve this problem in O(n).
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.