Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Insert and shift middle index of array

Given an array and a new item, create a new array with item in the middle of input array's values.

Challenge

Algorithm input consists of an array or similar language data structure, and a new item to be inserted. Output should be a new array with all items from the input array in the original order and the new item inserted in the middle. No standard library solutions for array manipulation are to be used. In the case of an even array length the middle position is rounded up.

The stretch goal is to provide an algorithm that inverts the operation on the array contents.

Solution

Whiteboard Images