Explanation

574.Delete an Element at a Position

Easy
Given an array nums and a position index, return a new array with the element at that position removed. The elements after it move one place to the left. Deletion is the reverse of insertion: instead of opening a gap, the later elements shift leftShifting LeftMoving each element one position towards the front, overwriting the element being removed. to close one. The cost again depends on position — removing near the front moves almost everything, removing the last element moves nothing.

Example 1:

Input: nums = [4,8,15,16], index = 1

Output: [4,15,16]

Example 2:

Input: nums = [9], index = 0

Output: []

+ 4 hidden test cases run on Submit.

Constraints:

  • ●1 ≤ nums.length ≤ 1000
  • ●0 ≤ index < nums.length
  • ●-1000000 ≤ nums[i] ≤ 1000000

nums =

[4, 8, 15, 16]

index =

1