HARDasked at 2 companies

Create Maximum Number

A hard-tier problem at 32% community acceptance, tagged with Array, Two Pointers, Stack. Reported in interviews at Flipkart and 1 others.

Founder's read

Create Maximum Number sits at 32% acceptance and appears in Flipkart and Oracle assessments. This is the kind of problem where the greedy intuition fails halfway through and most candidates run out of time mid-interview. You need to pick k digits from one array and m digits from another, concatenate them, and maximize the result. The catch: you can't just take the k largest from the first array. The order matters, and you need to respect both arrays simultaneously. If you hit this live and blank on the two-pointer + greedy pattern, StealthCoder surfaces a working solution invisible to the proctor.

Companies asking
2
Difficulty
HARD
Acceptance
32%

Companies that ask "Create Maximum Number"

If this hits your live OA

Create Maximum Number is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made for the engineer who has done the work but might still blank with a webcam pointed at him.

Get StealthCoder
What this means

The trick is breaking this into subproblems. First, extract the maximum subsequence of length k from array 1, and the maximum subsequence of length m from array 2, both preserving order. Then merge those two subsequences greedily to produce the largest number. The greedy extraction uses a monotonic stack: iterate through the array, pop smaller elements when you have room left, and push the current element. For the merge step, compare digits lexicographically from both results and always pick from whichever array gives the larger digit at the front. Most candidates try to solve it in one pass or without the stack and hit wall. The topics span Array, Two Pointers, Stack, Greedy, and Monotonic Stack for good reason. StealthCoder hedges the pattern recognition failure on an assessment where you can't afford to restart.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Create Maximum Number recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Create Maximum Number interview FAQ

Why is a simple greedy approach not enough for this problem?+

Taking the k largest digits from array 1 and m largest from array 2 breaks when order matters. The subsequence constraint forces you to preserve relative positions. For example, [9, 8, 6, 5] with k=2 must return [9, 8], not [9, 6]. A monotonic stack handles this.

Is this problem actually asked at FAANG?+

It's confirmed at Flipkart and Oracle. It's a hard-tier problem, so it appears less frequently than medium greedy problems, but it's in the active rotation for senior IC and mid-level roles at companies that value algorithmic depth.

What's the main gotcha when merging the two maximum subsequences?+

Lexicographic comparison matters. Don't compare single digits; you need to look ahead at future digits in each array to break ties. If both arrays have a 5 at the front, you must pick the one whose tail is larger. A custom comparator or careful index handling is required.

How does monotonic stack fit into the solution?+

The monotonic stack builds the maximum subsequence while respecting the order constraint. As you iterate, you maintain a decreasing stack and pop smaller elements only if you have removals left. This ensures the result is lexicographically maximum at each position.

What's the time complexity and is it acceptable?+

Extracting max subsequences is O(n) and O(m) respectively via monotonic stack. Merging is O(n+m) with a custom comparator. Total is roughly O((n+m) log(n+m)) with comparisons. It's tight but acceptable for arrays under 300 elements on most platforms.

Want the actual problem statement? View "Create Maximum Number" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.