MEDIUMasked at 1 company

The Number of Weak Characters in the Game

A medium-tier problem at 44% community acceptance, tagged with Array, Stack, Greedy. Reported in interviews at Pinterest and 0 others.

Founder's read

You're looking at a medium problem that shows up rarely in reports, but when it does hit your live assessment, it's a sorting and greedy trap. The Number of Weak Characters in the Game tests whether you can spot the real constraint and avoid the obvious solution that fails on sorted edge cases. Pinterest has asked it. If you blank on the greedy pattern mid-interview, StealthCoder runs invisibly and surfaces a working solution in seconds, so you don't tank the problem.

Companies asking
1
Difficulty
MEDIUM
Acceptance
44%

Companies that ask "The Number of Weak Characters in the Game"

If this hits your live OA

The Number of Weak Characters in the Game 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 by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know.

Get StealthCoder
What this means

The trick is recognizing that a character is weak if another character beats it on both attack and defense. A brute force compare-all-pairs approach times out. The greedy move is to sort by one attribute, then scan and track the running max of the other to count weak characters in linear time. The trap: simple sorts fail when two characters tie on the primary attribute. You need to sort attack ascending but defense descending when attack values match. This breaks the naive iteration. Most candidates miss the secondary sort order and blow time debugging off-by-one results. If this pattern doesn't click during your OA and you're stuck, StealthCoder solves the sort order and counting logic instantly.

Pattern tags

The honest play

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

The Number of Weak Characters in the Game 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. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know. Works on HackerRank, CodeSignal, CoderPad, and Karat.

The Number of Weak Characters in the Game interview FAQ

Is this really a medium, or is the acceptance rate lying?+

44% acceptance is legitimately medium-hard. The problem reads simple, but the two-attribute sorting logic and greedy counting trip up candidates who don't think through edge cases. It's less about data structures and more about pattern recognition under pressure.

Do I need a stack or monotonic stack for this?+

No. Stack is listed in topics because it's a common wrong approach. The actual solution uses sorting and a single pass with a running max. Monotonic stack overcomplicates it. Sort, then iterate with one pointer and a max tracker.

What's the greedy insight I'm missing?+

Once you sort by attack ascending (with defense descending on ties), you scan left to right. The max defense you've seen so far is your threshold. Any character with defense below that max is weak. Greedy: you don't need to compare every pair because the sort order guarantees you've already seen the dominators.

Does Pinterest still ask this, or is it old data?+

It's reported once in our data, so it's in their pool. Interview patterns shift, but greedy and sorting problems stay relevant. Treat it as a live possibility if you're interviewing there.

What if I mess up the sort order in the interview?+

You'll get wrong counts on test cases where attack values tie. Your logic will look right but fail on edge cases. That's where a live check with examples saves you, or StealthCoder flips the secondary sort and you move on.

Want the actual problem statement? View "The Number of Weak Characters in the Game" 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.