FastPrepRussian Doll Envelopes
Problems/Russian Doll Envelopes

Russian Doll Envelopes

InMobi logoInMobi● HardFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an InMobi onsite interview. The report names a problem like Russian Doll Envelopes but does not describe the change. This version uses the usual rules. It is about 92% the same as that kind of reported task.

You are given a two-dimensional integer array envelopes, where envelopes[i] = [width_i, height_i] describes one envelope.

One envelope can fit inside another only when both its width and its height are strictly smaller than the other envelope's dimensions. Envelopes cannot be rotated.

Return the maximum number of envelopes that can be nested inside one another.

Function

maxEnvelopes(envelopes: int[][]) → int

Examples

Example 1

envelopes = [[5,4],[6,4],[6,7],[2,3]]return = 3

One maximum nesting chain is [2,3] -> [5,4] -> [6,7], which contains 3 envelopes.

Example 2

envelopes = [[1,1],[1,1],[1,1]]return = 1

Equal dimensions are not strictly smaller, so no two envelopes can be nested.

Constraints

  • 1 <= envelopes.length <= 10^5
  • envelopes[i].length == 2
  • 1 <= width_i, height_i <= 10^5

More InMobi Onsite Interview questions

  • Minimum and Maximum with Optimal ComparisonsONSITE INTERVIEW · Seen Dec 2025
  • Minimum Edges to Connect All ComponentsONSITE INTERVIEW · Seen Dec 2025
  • Shortest Path Visiting All NodesONSITE INTERVIEW · Seen Sep 2025
  • Maximum Sum of Non-Adjacent Tree NodesONSITE INTERVIEW · Seen Jan 2022
  • Word SquaresONSITE INTERVIEW · Seen Jan 2022
  • Maximum Length Pair ChainONSITE INTERVIEW · Seen Jul 2021
  • Top View of a Binary TreeONSITE INTERVIEW · Seen Jul 2021
  • Maximum XOR Between Two ArraysONSITE INTERVIEW · Seen May 2021
  • Trapping Rain WaterONSITE INTERVIEW · Seen May 2021
  • Validate Binary Search TreeONSITE INTERVIEW · Seen May 2021

Similar questions at other companies

  • Russian Doll EnvelopesGoogle · ONSITE INTERVIEWGoogle interview questions
  • Russian Doll EnvelopesAirbnb · ONSITE INTERVIEWAirbnb interview questions
  • Maximum Total Length of Non-Overlapping IntervalsBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Maximum Profit in Job SchedulingAmazon · PHONE SCREEN
  • Fill a Time Window with SongsMicrosoft · OAMicrosoft interview questions
  • Maximum Taxi EarningsWells Fargo · OAWells Fargo interview questions
  • Count Later Lower ReadingsRippling · ONSITE INTERVIEWRippling interview questions
  • Minimum Total Waiting Time for One ElevatorExpedia · ONSITE INTERVIEWExpedia interview questions
  • 3Sum SmallerSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Minimum Removals for a Nice ArrayAdobe · ONSITE INTERVIEWAdobe interview questions
All InMobi interview questionsSee InMobi hiring insights
Saved
class Solution {
    public int maxEnvelopes(int[][] envelopes) {
        // Write your code here.
    }
}
Checking account…