if there any alternative for nested loops to reduce execution time?

different Algorithm.

that is what i asked sir,

You can come up with different alternatives for different questions.

For exempting loops, you need to think differently about the problem.

A good approach would be:

- Write down the possible test cases (mainly boundary cases).
- Write down the outputs for them that you get by simply solving the problem mathematically.
- Try finding out a relation between the noted inputs and their corresponding outputs (there definitely is one alternative if youâ€™re getting TLE by naive approach).

Try this thing for the problem and you will hit a super simple relation between the inputs and outputs.