Robinhood Codesignal New Grad OA

avatar 658158
Pickel
4747
5
第一次发帖,求大米。

q1: freebie

q2: Given an array, shift the index 0 to the back of the array and repeat. Return true if the array is a cyclic identity array or the reverse of a cyclic identity array, else false. A cyclic identity array is [1,2,3,4, ..., len(arr)], the reverse of a cyclic identity array is [len(arr), 8, 7, ..., 4,3,2,1]. So [5,1,2,3,4] should return true because [5,1,2,3,4] -> [1,2,3,4,5] and [1,2,3,4,5] is a cyclic identity array.

q3: Given a 2d matrix. if matrix[j] == "F", then that cell is a part of a connected figure. if matrix[j] == "#", then that cell is a obstacle. if matrix[j] == "." then its empty. Gravity applies, the connected figure will fall down from the matrix. Make the figure fall until any of the figure hits an obstale or the ground.

q4: Given an array, find the number of subarrays that contain each of its numbers at least twice. So [0,0,0] should return 3 because [0,0] from index0 ~ index1, [0,0,0] from index0 ~ index2, and [0,0] from index1 ~ index2
  • 4
5条回复