Please check my code. I am only getting one test case correct and getting TLE on many cases and wrong answer in one test case
Only one test case is correct
Your code follows n^2 time complexity that is why it shows tle on many cases. Try to find a optimised logic for the given code in question so that it produces same output in more efficient way.