My LeetCode grinding. Trying to do a problem a day.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

problem.txt 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. Given two arrays of integers nums and index. Your task is to create target array under the following rules:
  2. Initially target array is empty.
  3. From left to right read nums[i] and index[i], insert at index index[i] the value nums[i] in target array.
  4. Repeat the previous step until there are no elements to read in nums and index.
  5. Return the target array.
  6. It is guaranteed that the insertion operations will be valid.
  7. Example 1:
  8. Input: nums = [0,1,2,3,4], index = [0,1,2,2,1]
  9. Output: [0,4,1,3,2]
  10. Explanation:
  11. nums index target
  12. 0 0 [0]
  13. 1 1 [0,1]
  14. 2 2 [0,1,2]
  15. 3 2 [0,1,3,2]
  16. 4 1 [0,4,1,3,2]
  17. Example 2:
  18. Input: nums = [1,2,3,4,0], index = [0,1,2,3,0]
  19. Output: [0,1,2,3,4]
  20. Explanation:
  21. nums index target
  22. 1 0 [1]
  23. 2 1 [1,2]
  24. 3 2 [1,2,3]
  25. 4 3 [1,2,3,4]
  26. 0 0 [0,1,2,3,4]
  27. Example 3:
  28. Input: nums = [1], index = [0]
  29. Output: [1]
  30. Constraints:
  31. 1 <= nums.length, index.length <= 100
  32. nums.length == index.length
  33. 0 <= nums[i] <= 100
  34. 0 <= index[i] <= i