Staff SE - Back End | Pair Coding Round | Agoda
- Posted
- 8 Jun 2026
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.
How it went
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.
Questions asked (2)
- 01
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).
- 02
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.