Wrote the brute force solution on my own.
Giving TLE for one test case-
Wrote the brute force solution on my own.
Giving TLE for one test case-
Yes brute force approach will be like this only, now think something related to map. And then try to solve as the test case you are failing is because it would be solved using optimized approach using maps.
What is the use of the position array that was mentioned in the hint video? How will it help?
Now you are clear with the brute force, now think it by using hashmap or unordered map. The hint to solve the problem is that the given array will always contain permutation of the first N natural numbers.(that is number from 1…N). So we will prepare a map which will contain element as the key and the index at which it is present as the value.
So do what,
I tried to optimize it using map but i think the code again came out to be a brute force one, now giving TLE for 2 cases 
Code - https://ide.codingblocks.com/s/407081
I didn’t know how to optimize the printing of the map, can you check once.
Can you help me optimize this approach?
Use unordered map instead of map, and then let me know if it gets accepted or not.
Yup, still giving TLE
Check Now =>
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.