Back to General discussions forum
input data: 4 3 1 2 5
answer: 1 1 0
I have an idea how the algorithm works, but I don't know what the answers 1 1 0
mean.
3 (start)
_ 3 1 element shifted
1 3
1 _ 3 1 element shifted
1 2 3
1 2 3 _ 0 element shifted
1 2 3 5
What happened to the 4?
Four is the number of the elements in the list. As the problem says:
Input data will contain N - the size of array - in the first line. Next line will contain the array itself (all elements will be different).