FastPrepFind the Pivot Element
Problems/Find the Pivot Element

Find the Pivot Element

Agoda logoAgoda● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report states the strict pivot rule: everything on the left is smaller and everything on the right is greater. It leaves out the edge positions and what to do when there is no answer. Here only inner positions count, and we return the value of the leftmost pivot. We return -1 when there is none, since inputs are never negative.

Our version is about 94% the same as the reported question.

You are given an array nums of distinct nonnegative integers. A pivot is an element where every element to its left is strictly smaller and every element to its right is strictly greater.

Only an internal element can be a pivot, so its index must be between 1 and nums.length - 2. Return the value of the leftmost pivot. Return -1 when no pivot exists.

Function

findPivotElement(nums: int[]) → int

Examples

Example 1

nums = [5,1,4,3,6,8,10,7,9]return = 6

Only one internal value has every value before it smaller and every value after it greater. That value is the pivot, so the answer is 6.

Example 2

nums = [1,2,3,4,5]return = 2

The values are in increasing order, so every internal value is a pivot. The leftmost pivot is the answer: 2.

Example 3

nums = [4,2,5,1,7]return = -1

No internal value is greater than every value on its left and smaller than every value on its right. There is no pivot, so the answer is minus one.

Constraints

  • 3 <= nums.length <= 2000
  • 0 <= nums[i] <= 10^9
  • All values in nums are distinct.

More Agoda Phone Screen questions

  • Sort Ones, Twos, and Threes In PlacePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Can Place FlowersPHONE SCREEN · Seen Nov 2026
  • Reverse Words in a StringPHONE SCREEN · Seen Nov 2026
  • Disk Space Window AnalyzerPHONE SCREEN · Seen Sep 2026
  • Shortest Subarray With the Full DegreePHONE SCREEN · Seen Sep 2026
  • Enumerate Weekly Work SchedulesPHONE SCREEN · Seen Sep 2026
  • Count Values Appearing Exactly OncePHONE SCREEN · Seen Sep 2026
  • Longest All-Present Attendance StreakPHONE SCREEN · Seen Sep 2026
  • Chemical Formula WeightPHONE SCREEN · Seen Sep 2026
  • Maximum Planes Destroyed Before LandingPHONE SCREEN · Seen Jan 2026

Similar questions at other companies

  • Peak Chat Load Across AgentsCresta · PHONE SCREENCresta interview questions
  • Trapping Rain WaterGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • Best Improvement Period of at Least K IntervalsAmazon · PHONE SCREEN
  • Majority Labels over Audio IntervalsNooks · PHONE SCREEN
  • Random Pick with Weight Using Recorded DrawsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Maximum Sum Desirable SubarrayGroww · PHONE SCREEN
  • Hash Partition OffsetsNVIDIA · PHONE SCREENNVIDIA interview questions
  • Instrument Stack Language JumpsJane Street · PHONE SCREENJane Street interview questions
  • Maximize Compatible Car RidersUber Freight · PHONE SCREEN · ONSITE INTERVIEWUber Freight interview questions
  • Product of Array Except SelfCapgemini · PHONE SCREENCapgemini interview questions

Agoda interview experiences

  • Agoda Staff Backend OA Questions: 5 Experiences
All Agoda interview questionsSee Agoda hiring insights
Saved
class Solution {
    public int findPivotElement(int[] nums) {
        // write your code here
    }
}
Checking account…