Unlock- Hashing

Why is test case 0 showing Run Error? https://ide.codingblocks.com/s/227247

you are using out of bound indexing in line 8, variable i goes from n to 1 instead of n-1 to 0. This will eliminate your runtime error.

Sir, since the permutations are given of first n natural numbers and i have build my code accordingly, please see my logic,variable i basically represents each of the first n permuations so that have to be from 1 to n and not 0 to n-1. I also changed it to 0 to n-1 as you said, but then all the 4 test cases failed, bcoz permutations are from 1 to n. Please tell what to do now

Yes you are right , the only problem with your code seems that put AND condition here
for(int i=n;i>0&&k>0;i–), try this

Okay sir…Got it! Thank you !!!