Data StructuresEasy

Delete in Array

Deleting an Element

Delete Element

To delete an element at a given index idx in an array of size N, you must shift all elements from index idx + 1 to N - 1 one position to the left to fill the gap. The total number of elements decreases by 1.

Edge Cases

  • Array is empty: Nothing to delete.
  • Invalid index: Index is less than 0 or greater than N - 1.