My code has passed all test cases in leetcode but getting TLE on test case 4. Please help.
Getting TLE on test case 4
@yashkirat your solution approach is correct, actually the last case has n=10000, , so a little bit of optimization will work!
https://ide.codingblocks.com/s/294510
Got, it all accepted.