Staff SE - Back End | Pair Coding Round | Agoda

agoda logo
agoda
· Staff Software Engineer - Back End
June 8, 2026 · 0 reads

Summary

I took part in a pair coding round at Agoda for a Staff Backend Software Engineer position, where I was asked two algorithmic questions.

Full Experience

Hi Folks,

Number of Questions: 2

I was asked the following two questions in a recent coding interview. I dont remember the exact input/output examples for both the problems, but the problem statements were roughly as follows:

Q1: Given an array, find all pairs of elements whose difference is equal to the minimum absolute difference in array. input = [1,3,10,7,5] output = [[1,3], [5,7]] (as minimum absolute diff in any 2 elemnents of array is 2)

Q2: Given an array, for each element, find the distance (gap/index difference) to the next smaller element on its right. This problem can be solved using monotonic stack.

Interview Questions (2)

1.

Find All Pairs with Minimum Absolute Difference

Data Structures & Algorithms

Given an array, find all pairs of elements whose difference is equal to the minimum absolute difference in the array.

Example

input = [1,3,10,7,5]
output = [[1,3], [5,7]]

The output contains all pairs whose absolute difference equals the smallest possible absolute difference among any two elements in the array (which is 2 in the example).

2.

Next Smaller Element Distance to the Right

Data Structures & Algorithms

Given an array, for each element find the distance (index gap) to the next smaller element on its right.

Hint: This problem can be solved using a monotonic stack.

📣 Found this helpful? Please share it with friends who are preparing for interviews!

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!