Pergunta de entrevista da empresa Bloomberg

Find the first two largest numbers in an array of integers.

Respostas da entrevista

Sigiloso

11 de out. de 2013

int k = 2; int[] largestK = new int[k]; for(int i = 0; i min) largestK[minPos] = input[i]; } return largestK;

Sigiloso

23 de jan. de 2015

vector findLargest(vector input){ int max, max2; max = max2 = input[0]; for(int i = 0; i max){ max2 = max; max = input[i]; } else if(input[i] > max2) max2 = input[i]; } cout << max << endl << max2 << endl; }