Pergunta de entrevista da empresa Agoda

write algorithm which will reverse array, without using std tools

Respostas da entrevista

Sigiloso

24 de jan. de 2019

int[] array = {1,2,3,4,5}; int left = 0, right = array.length - 1; while (left < right) { int temp = array[left]; array[left] = array[right]; array[right] = temp; left++; right--; } System.out.println(Arrays.toString(array));

1

Sigiloso

25 de jan. de 2021

In these sorts of interviews you really need to drill down and understand what the interviewer is looking for. A good way to simulate a real interview experience is to do a mock with one of the Agoda Full Stack Engineer experts on Prepfully, rated super strongly on TrustPilot... prepfully.com/practice-interviews

1

Sigiloso

9 de jan. de 2018

start with two pointers (references) to the first and last elements in the array. repeat while the index of 'last is greater than the index of 'first: - swap the values of array[first] and array[last] using a temp variable - increment the value of 'first' and decrement the value of 'last'