Plates Between Candles
A medium-tier problem at 47% community acceptance, tagged with Array, String, Binary Search. Reported in interviews at Amazon and 1 others.
Plates Between Candles is a medium-difficulty array problem that Amazon and Oracle ask in their online assessments. You're given a string with plates and candles, then answer queries about how many plates sit between candles in a range. The trap is thinking you need to recompute per query. The actual move is prefix sums and binary search to answer each query in constant time. With a 47% acceptance rate, plenty of candidates miss the optimization and timeout. If this problem hits your live OA and you blank on the pattern, StealthCoder surfaces the working solution in seconds, invisible to the proctor.
Companies that ask "Plates Between Candles"
Plates Between Candles 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 by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share.
Get StealthCoderThe naive approach iterates through the string for each query, checking which plates fall between candles in that range. It works on small inputs but fails on large test cases due to repeated work. The trick is precomputing a prefix sum array of plate counts, then using binary search to find the nearest candles at or past the query boundaries. This shrinks each query from linear to logarithmic time. Common failures include forgetting that a candle must exist at or inside the range for plates to count, or building the prefix sum incorrectly and over-counting plates outside candle pairs. The problem combines Array, String, Binary Search, and Prefix Sum in a way that looks straightforward until the time limit hits. StealthCoder's hedge here is critical because the optimization isn't obvious without seeing the pattern once.
Pattern tags
You know the problem.
Make sure you actually pass it.
Plates Between Candles 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 by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Plates Between Candles interview FAQ
Is Plates Between Candles still asked at Amazon and Oracle?+
Yes. Both companies report asking it in their online assessments. The 47% acceptance rate suggests it's not a warm-up, so expect it on a real OA. If you hit it unprepared, StealthCoder bridges the gap between blank and passing in seconds.
What's the trick to getting it right in one pass?+
Build a prefix sum of plate counts as you scan the string, then use binary search to find valid candle boundaries for each query. This avoids re-scanning the string per query. Most timeouts happen because candidates don't precompute, forcing O(n*m) logic when O((n+m)*log n) is required.
How does Prefix Sum help here?+
Prefix Sum lets you compute total plates in any range in constant time after one O(n) setup pass. Combined with binary search to locate candle positions, you can answer each query instantly instead of iterating. This is the core insight that separates accepted from timed-out solutions.
Does Binary Search do anything special here?+
Yes. After precomputing which positions have candles, binary search finds the leftmost candle at or after your left boundary and the rightmost candle at or before your right boundary. Without it, you'd still scan candle positions per query, killing performance.
What's the common mistake on edge cases?+
Counting plates when no valid candle pair exists in the range, or including plates outside the candle boundaries. Always check that left and right boundaries contain or are surrounded by candles. Off-by-one errors on index checks cost a lot of submissions.
Want the actual problem statement? View "Plates Between Candles" on LeetCode →