If you are stuck on a geeksforgeeks problem, and need help, please read this first.
The first thing I suggest you do, is read through all the comments to see if anything relates to your difficulty. You may not find anything, but while you are looking, make a list of ALL the test cases mentioned, then test your code with those test cases.
When you press Submit, your code is tested with some input containing many test cases. When your code fails, it shows you the first test case that it failed on.
If your code gives the wrong answer when you press Submit, but gives the correct answer when you test with that test case, your code probably doesn't handle multiple test cases correctly.
Use the Compile & Test button AND check that your answer is correct.
Always test your code with multiple test cases.
If you want to be a programmer, test your code thoroughly, before you press Submit.
Make it easy for people to help you. I don't respond to "Whats wrong with this?"
Indent your code sensibly.
Explain why you are stuck.
Show your code by using https://ide.geeksforgeeks.org/ to generate a URL, and share that URL. Include multiple test cases. If possible, make sure that pressing "Run", runs your code, so if it's a function problem, include the driver code.
With TLE, there are three possibilities
In C/C++ the stack is about 8 megabytes and the heap about 120 megabytes. Inside a function, if you have the automatic variable long long arr; you've just about used all the stack!
To be continued