Google Interview Report
- 0of 0 votes
AnswersYou are given a positive integer number N. Return the minimum number K, such that N can be represented as K integer squares.
- Anonymous January 27, 2015 in Israel
Examples:
9 --> 1 (9 = 3^2)
8 --> 2 (8 = 4^2 + 4^2)
15 --> 4 (15 = 3^2 + 2^2 + 1^2 + 1^2)
First reach a solution without any assumptions, then you can improve it using this mathematical lemma: For any positive integer N, there is at least one representation of N as 4 or less squares.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 1of 1 vote
AnswersYou are given a double linked list and an array of pointers to elements in this list (no assumptions can be made on the array - number of pointers, order and duplicates allowed).
- Anonymous January 27, 2015 in Israel
Return the number of sequences of elements (groups of consecutive elements), pointed by the array.
For example, if this is the array (number relates to index in the list, not the actual pointer value): 9,1,3,7,8,5,2.
Then output is 3, representing these sequences: [1,2,3], [5], [7,8,9]| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Data Structures