What is the error in my unlock code using hashing
@D19APPPP0016 It is a very simple problem. You can just check if your n-j-1 is at it’s actual position or not . If not swap it with it’s actual position.
Instead of using map I would recommend you to use an array. Which would be much more simple to implement.
Bro its to be implemented using hashing
Please find the error in my code.
@D19APPPP0016 I’m asking you to write a simpler code with array .I’m unable to understand what you’ve written. You can map the values inside the array as well and solve this problem.
The problem has constraints of 10^9 ,can,t be solved using array as hashmaps in O(N).
If you can,t solve it ,hand over to different TA.
@D19APPPP0016 The value of n can be at max 10^5. And the constraint which you are taking about is the max value of A[I]. So it can be solved.
@D19APPPP0016 As I can see in your code you are taking input from 0 and going up to n-1. Take it from 1 and go up to n. It might help you out. Also useap instead of unordered map because might change the order of values.
Kindly provide the solution and then say anything
Anyways u are from which college
@D19APPPP0016 https://ide.codingblocks.com/s/200078 Please have a look into this code . And try writing cleaner and simpler code .
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.