Unlock problem in hashing

https://ide.codingblocks.com/s/370928 unlock problem in hashing is not passing test cases pls dont change the entire code

Hey @shrutikatyal you have posted same doubt as Your previous doubt in which your doubt as been acknowledged . Still you have an issue or your doubt hasn’t been resolved you can ask it again. Will be happy to help.

when i dry run my code its showing correct output .

The algorithm is:

  1. Create the map by filling the number as the key and the index at which it is present as the value
  2. Iterate over the whole array.
  3. For element at a particular index m we will check if it is present at its best spot or not.
  4. The best spot of any number num is the N-num index of the array.
  5. If the number is not present at its best spot then we will swap the number with element present at that spot.
  6. As we have stored the index of every element in the map we can easily retrieve that from the map to get the swap done.

Try to dry run this and see where were you wrong while implementing this logic

i have checked my logic multiple times which is same as given by ur algorithm can you pls tell at what step i am going wrong .

Issue is in line number 29 & 30 of your code, as it has been mentioned on your previous post .

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.