Google L3 onsite question 2022
Anonymous User
1394

Was asked this question in my google onsite for L3 position

Q. given a list of google chrome tabs represented as a array of integers i.e, [1,2,3,4,7,8,9,10]
a move(int tab, int index) function will move one tab specified in the 'tab' parameter to the location in the array specified by the index parameter. eg. move(10,1) will move tab 10 to the first index in the array. [1, 10, 2, 3, 4 , 7, 8, 9]
write a function move([tab_group], int index) that moves a group of tabs at once to the specified index. eg.

move([10,9,8,7], 1) this would give [1,10,9,8,7,2,3,4]

the elements in the array can be modified only by using the move(int tab, int index) function.

  1. the goal is the minimize the number of calls to the original move. i.e, call move(int tab, int index) only once to move the entire tab group to the specified index in move([tabgroup], index)
  2. the implementation of move(int tab, int index) is already give. its part of the chrome api. we dont need to worry about the implementation details.
  3. the tabgroup should be represented by a number that is part of the tabgroup subset
Comments (2)