MEDIUMasked at 1 company

Maximum Number of Consecutive Values You Can Make

A medium-tier problem at 62% community acceptance, tagged with Array, Greedy, Sorting. Reported in interviews at Infosys and 0 others.

Founder's read

You have an array of coins with given denominations. The problem asks: what's the maximum number of consecutive integer values you can form, starting from 1, using any subset of those coins. Infosys has asked this one. It's not a coin-change problem in disguise, and the greedy insight most people miss on first read will cost you 20 minutes in a live assessment. If you haven't seen the exact pattern, StealthCoder runs invisibly during your OA and surfaces a working solution in seconds.

Companies asking
1
Difficulty
MEDIUM
Acceptance
62%

Companies that ask "Maximum Number of Consecutive Values You Can Make"

If this hits your live OA

Maximum Number of Consecutive Values You Can Make 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. Built because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround.

Get StealthCoder
What this means

The trick is greedy sorting and a running sum check. Sort the coins, then iterate through them. At each step, ask: can I form all values from 1 to my current maximum with what I have so far. If the next coin is larger than current_max plus one, there's a gap and you stop. If not, you can extend your range. The obvious brute-force approach tries to enumerate all subsets, which fails on larger inputs. The greedy approach is O(n log n) and relies on a single insight: if you can make 1 through k, and the next coin is at most k+1, you can now make 1 through k plus that coin's value. When you hit the assessment and feel the solution isn't clicking, StealthCoder bridges that gap.

Pattern tags

The honest play

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

Maximum Number of Consecutive Values You Can Make recycles across companies for a reason. It's medium-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. Built because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Maximum Number of Consecutive Values You Can Make interview FAQ

Is this really a medium problem?+

The acceptance rate of 62% suggests it sits at the harder end of medium. Most candidates miss the greedy pattern and waste time on exponential solutions. Once you see the insight, it's straightforward. Most interviewers ask follow-ups on coin combinations or gaps, so expect depth.

How does this relate to the greedy topic?+

Greedy is central. You build the consecutive range greedily by always taking the next coin if it doesn't create a gap. The proof is that if you skip a coin that fits, you never improve your maximum. This is a classic greedy correctness problem.

What's the common mistake?+

Trying to solve it like a subset-sum or coin-change DP problem. That's exponential or pseudo-polynomial and crushes your runtime. The greedy observation cuts the problem to a single pass. Also, forgetting to handle the edge case where the first coin isn't 1.

Do I need to track which coins I actually use?+

No. The problem only asks for the count of consecutive values you can form. You track the maximum consecutive value you can reach and return it. Knowing which coins you pick is unnecessary for the answer.

Is Infosys the only company asking this?+

According to available reports, yes. That said, the problem structure appears in internship and early-career assessments. If Infosys is on your list or you're prepping for that funnel, this pattern is worth owning cold.

Want the actual problem statement? View "Maximum Number of Consecutive Values You Can Make" 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.