Trying to solve a leetcode problem right now and think I have an idea for a solution but need some help. I am given 2 lists: 1 is a list of values, and the other is the index value where I should place such values. Such as below:
nums = [1, 5, 3]
index = [0, 1, 2]
So, I would have to append number 1 at index 0, 5 at index 1, etc.
I have solved the problem with simple while loop but now I want to solve the problem with a dictionary, so I have made this so far:
list2 = []
ans = dict(zip(nums, index))
list2.insert(someindex, somenumber)
My question is how I can access the data in the dictionary to finish my insert command. how can I replace the code at 'someindex' and 'somenumber' to represent the index and corresponding value stored in my dictionary? Is this possible? Thanks for the help