Domanda di colloquio di Agoda

write algorithm which will reverse array, without using std tools

Risposte di colloquio

Anonimo

24 gen 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

Anonimo

25 gen 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

Anonimo

9 gen 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'