One Dimensional Array Element Delete
tags: array-delete array-left-shift two-way-comparison array-copy strict-comparison
Delete an element at a given index in an array.
Solution Outline
- Create a temporary array of size one less than the input array.
- If the loop index is less than the delete index copy the elements to the temporary array.
- If the loop index is greater than the delete index, copy the elements one location to the left to fill in the gap for the element deleted.
- Change the input array reference to temporary array
- Return the input array
|
|