Create an integer array of size on the heap, and insert -1 into every element
Increase the size of your array by 1 element:
allocate space for a new array
copy the values over
make the last value 1, instead of negative 1.
Double the size of your array, copying the values from the first half to the second half
Reduce the size of the array by half, only keeping the first half values
Remove the first element from the array, and shrink the array by one. The resulting array should be exactly like the previous, only missing the first element.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here