for i in new_nums: ans[i-1] = new_nums.index(i)+1
My Python is not great, but I believe this is O(n^2), and n can be as high as 10^5.
I am new to programming so I am not familiar with some stuffs. But it passes all the test cases. Shouldn’t the problem arise while running the test cases?
The “problem” is that your algorithm is asymptotically too slow, so will mainly manifest for large testcases only.
Try creating a text file with the following contents:
First line: the number
Second line: all numbers from
100000, separated by spaces
Third line: the number
provide the contents of this text file as input to your solution and see how long it takes for your solution to process it