Google Interview Question for Software Developers
- -1of 1 vote
AnswersThe array of integers in given . The array indicates nothing but the heights of the cylinders. The robotic arm has two ends-> left and right.
- anaghakr89 July 31, 2017 in United States
The left end points to the left end of the cylinder array and right end searched for the cylinder with least height.
ex:
array = {4,5,6,7,1,2}
left end => index 0
right end =>index 0->n giving index 4 with min height
Now the entire block is rotated by 180 degree.
now the array = { 1, 7, 6, 5, 4, 2}
now the left end moves forward.
and right end will search from left index onwards till the end of the array
so left index = 1
right index => 1-> n giving index 5 as min. height
again do the block rotate .
Write the code for this particular algorithm.
However, there is one condition
1. If there are duplicates in the array then the final order of those duplicates should remain the same.
ex. If the cylinder with height 4 is appearing at index 3 and 5 in the initial array then the cylinder at index 3 should always appear before the one at index 5 in the final array.| Report Duplicate | Flag | PURGE
Google Software Developer
Interview Type: Phone Interview