Domanda di colloquio di Google

1) Code and analyse the function findMaximums(). 2) Use a sorted data structure (a binary tree). 3) std::vector<int> findMaximums(int* Data, int N, int K) where 4) Data is an array of int's. 5) N is the size of the array Data. 6) K is the number of element from Data you want to compare and maximize. 7) The vector you return is the list of these "local maximums".

Risposte di colloquio

Anonimo

30 ott 2011

std::vector findMaximums(int* Data, int N, int K) { std::vector list; qsort(Data, n, sizeof(int), compare); for (int i = N ; i--; i>0) { if (Data[i]>K) list.push_back(Data[i]); else break; } return list; }

1

Anonimo

3 lug 2011

Don't bother with this one, move on to a better job and employer like I did. If you really want to work for an American company read "Programming Interviews Exposed". You'll get offer from the companies you want to work with.