Here is the code of the question implemented:- https://ide.codingblocks.com/s/455160, of the question:-https://leetcode.com/problems/permutation-sequence/, please specify the error in the code because it is not giving expected output.
Permutation Sequence Backtracking
But it is still not getting submitted. Showing wrong answer for the test case 3 5, the sequence is different from what we are getting from the code and the answer expected.
the permutation that u are generating are not in sorted order.
so after generating all permutation sort ur ans vector and then print
Now the time limit is exceeded, is there any other method to solve this question. And also how we will calculate the time complexity of this code, unable to figure out how to find it.
…
u next permutation function and run it till count < k .
build recurrence tree and see how much time u are spending on each transisiton
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.