FastPrepMaximum Students With Limited Height Changes
Problems/Maximum Students With Limited Height Changes

Maximum Students With Limited Height Changes

Adobe logoAdobe● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Adobe online assessment for full-time roles. The original discussion describes the chosen students standing in ascending height order. Some comments also use the word subsequence. Our version says plainly that you may pick students and reorder them, instead of keeping the input order. The report gives the 1,000 limits. We chose the function signature.

You may choose any subset of the students described by heights and rearrange the chosen students in nondecreasing height order.

At most x adjacent pairs in the arranged line may have different heights. Return the largest possible number of chosen students.

The input order does not constrain selection: you do not have to keep an original-order subsequence.

Function

maximumStudents(heights: int[], x: int) → int

Examples

Example 1

heights = [1,1,2,3]x = 1return = 3

Choose both students of height 1 and one of height 2. The sorted line [1,1,2] has one unequal adjacent pair. Three distinct heights would require two changes.

Example 2

heights = [2,1,2,1]x = 1return = 4

Reorder all four students into [1,1,2,2]. It has one height change, so all four can stay.

Constraints

  • 1 <= heights.length <= 1000
  • 1 <= heights[i] <= 1000
  • 1 <= x <= 1000

Source note: Screenshot of the public LeetCode discussion text describing the reported Adobe OA task. The practice version adds the details stated in the source note.

More Adobe Online Assessment questions

  • Base Unit ConversionsOA · Seen Nov 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
  • Top-Funded Villages and ProjectsOA · Seen Aug 2026
  • Count Parent Nodes With a Target SumOA · Seen Aug 2026
  • Largest Binary Number by ConcatenationOA · Seen Aug 2026
  • Count Events by CategoryOA · Seen Aug 2026
  • Graph M-ColoringOA · Seen Aug 2026
  • Hall of Shifting TilesOA · Seen Aug 2026
  • K-th Ancestor Subtree Preorder QueryOA · Seen Aug 2026
  • Maze ReachabilityOA · Seen Aug 2026

Similar questions at other companies

  • Minimum Non-Adjacent Selection CapabilityMicrosoft · OAMicrosoft interview questions
  • Earn the Most 🐝Capital One · OACapital One interview questions
  • Minimum Cost to Merge Values into OnePayPal · OAPayPal interview questions
  • Minimum Operations to Sort with Rotations Then SwapsBank of New York Mellon · OA
  • Minimum Cost of Left and Right PropagationAmazon · OA
  • Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
  • Reschedule Meetings for Maximum Free TimeFivetran · OAFivetran interview questions
  • Maximum Easy Tasks After RearrangingIBM · OAIBM interview questions
  • Maximum ScoreNVIDIA · OANVIDIA interview questions
  • Maximum Distinct Values After Unit AdjustmentsBirla Pivot · OA

Adobe interview experiences

  • Adobe New Grad OA: Unit Conversion and Code Review: 1 Experience
  • Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
  • Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
  • Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
  • Adobe New Grad MTS Interview Questions: 7 Experiences
  • Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)
All Adobe interview questionsSee Adobe hiring insights
Saved
class Solution {
    public int maximumStudents(int[] heights, int x) {
        // Write your solution here
    }
}
Checking account…