although i have use logn to solve pow but my sl. is showing tle please tell mistake.
https://ide.codingblocks.com/s/180444 is my code link
Why showing tle in 1 case
Your code is absolutely correct. But still it is prone to tle in tighter cases. Try these two things to reduce time.
- Whenever your pass a vector<vector> in the function use & to pass by reference as it does not make a copy and uses the same previous vector<vector> .
Eg : vector<vector> &a - In pow function use iterative method rather than recursion approach.
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.