+ 4

Not getting all permutations in my code....

Please help me find my mistakes 🙏 https://code.sololearn.com/ca17A25a1717/?ref=app

17th May 2021, 9:38 AM
[ ]
[     ] - avatar
10 odpowiedzi
+ 4
Instead of pushing full swapped s into recursion, put only a sliced tail into the the recursion. For inserting into Set, you only need to insert under the condition index == n at beginning of soln() code block.
17th May 2021, 1:01 PM
Gordon
Gordon - avatar
+ 2
ChillPill ty for replying and for ur suggestions ..... I knew about the function next_permuation() it's just that I'm still in learning phase so don't want to use built-in functions rather I would try to code them up And I couldn't use auto feature because I was coding in dev- c++ which was working in c++98 mode .... XD Aggghh I guess I should have changed some stuff before posting the code but still ty for everything
17th May 2021, 1:59 PM
[ ]
[     ] - avatar
+ 2
I got my mistake...... While again calling the soln function I should have used index+1 as a parameter instead of i +1 ......because index is responsible for slicing I is for swapping elements
17th May 2021, 2:52 PM
[ ]
[     ] - avatar
+ 1
👍
17th May 2021, 3:21 PM
Gordon
Gordon - avatar
0
ChillPill Hatsy Rei Gordon pls help 🙏
17th May 2021, 11:47 AM
[ ]
[     ] - avatar
0
Gordon I tried ur soln but still no luck...... I believe u meant this https://code.sololearn.com/cVAzPJdl4lAh/?ref=app
17th May 2021, 1:41 PM
[ ]
[     ] - avatar
0
Gordon ty for replying..... I forgot to mention that earlier.....sry
17th May 2021, 2:02 PM
[ ]
[     ] - avatar