FastPrepMinimum Queue Bribes
Problems/Minimum Queue Bribes

Minimum Queue Bribes

Expedia logoExpedia● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report's queue example [1,2,5,3,4] needs 2 bribes. This exercise keeps the rule that a person can move forward by at most 2 swaps. Impossible queues return -1. We chose the limits and what happens with an empty queue. Our version is about 97% the same as the reported question.

A queue begins with labels 1 through N in increasing order. One bribe swaps a person with the person immediately ahead. Each person may bribe at most twice, but may be pushed backward any number of positions.

Given the final permutation order, return the minimum total number of bribes needed. Return -1 if the permutation cannot be produced under that rule. Empty input returns 0.

Function

minimumBribes(order: int[]) → int

Examples

Example 1

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

Person 5 passes 4 and then 3, requiring exactly two bribes.

Example 2

order = [2,5,1,3,4]return = -1

Person 5 is three places ahead of the original fifth position, exceeding the limit.

Constraints

  • 0 <= order.length <= 10000.
  • 1 <= order[i] <= 10000.
  • order is a permutation of 1 through order.length.

More Expedia Onsite Interview questions

  • Scramble StringONSITE INTERVIEW · Seen Sep 2026
  • Smallest Sufficient TeamONSITE INTERVIEW · Seen Sep 2026
  • Check Anagram Pairs Index by IndexONSITE INTERVIEW · Seen Oct 2025
  • Fresh Oranges Left After Rotting StopsONSITE INTERVIEW · Seen Oct 2025
  • Longest Increasing SubsequenceONSITE INTERVIEW · Seen Oct 2025
  • Lowest Common Ancestor with Repeated and Missing ValuesONSITE INTERVIEW · Seen Oct 2025
  • Shortest Substring with Exactly K OnesONSITE INTERVIEW · Seen Oct 2025
  • Middle Element of a Linked ListONSITE INTERVIEW · Seen Nov 2024
  • Minimum in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Sep 2024
  • Mirror Image Binary TreesONSITE INTERVIEW · Seen Sep 2024

Similar questions at other companies

  • Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
  • Minimum Station Tracks for a Train ScheduleBNSF Railway · ONSITE INTERVIEWBNSF Railway interview questions
  • Best Time to Buy and Sell Stock IIKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Minimize Total Weight After HalvingAmazon · ONSITE INTERVIEW
  • Capacity to Ship Packages Within DaysMicrosoft · OA · ONSITE INTERVIEWMicrosoft interview questions
  • Gas StationeBay · ONSITE INTERVIEWeBay interview questions
  • Make an Array Non-Decreasing With One ModificationGoogle · ONSITE INTERVIEWGoogle interview questions
  • Wizard Scroll Allocation StrategyJane Street · ONSITE INTERVIEWJane Street interview questions
  • Maximize Compatible Car RidersUber Freight · PHONE SCREEN · ONSITE INTERVIEWUber Freight interview questions
  • Maximize Monsters DefeatedSalesforce · ONSITE INTERVIEWSalesforce interview questions

Interview reports that mention this question

  • Expedia New Grad SDE Oldest Loops: 4 Experiences (Part 3 of 3)

Expedia interview experiences

  • Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
  • Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
  • Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
  • Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
  • Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)
All Expedia interview questionsSee Expedia hiring insights
Saved
class Solution {
    public int minimumBribes(int[] order) {
        // Write your code here.
    }

}
Checking account…