AlgoFrames

Delete at index by shifting

Standard · Write code · about 8 min

Delete the value at index i from nums and return the array without it. Do it the way a fixed array must: move every later value one cell left, then drop the last cell.

Do not use built-in helpers such as splice, pop(i) or del.

Example 1

Input:

[[3,5,8,1,9,6],2]

Output:

[3,5,1,9,6]

Example 2

Input:

[[4,7],1]

Output:

[4]

Deleting the last value moves nothing.

Constraints

  • 1 ≤ nums.length ≤ 10,000
  • 0 ≤ i < nums.length

Learn the idea first: Arrays: indexing, traversal, insertion and deletion costs, a visual lesson.

More Arrays: indexing, traversal, insertion and deletion costs problems