Most Frequent Integer with Smaller Tie-Break
Reported by candidates from ByteDance's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
A hash map does almost all the work in this ByteDance OA question, reported in July 2026. You count how often each integer shows up, then pick the winner. The twist is the tie-break: when two values share the top frequency, you return the smaller one. It's a small problem, so the points go to clean code and zero silly bugs. If your mind goes blank on the tie rule, StealthCoder runs invisibly during the live OA and gives you a working solution as a safety net.
The problem
Given an integer array nums, return the value that appears most frequently. If multiple values have the same maximum frequency, return the smallest of those values. Function mostFrequentInteger(nums: int[]) → int Examples Example 1 nums = [4, 2, 4, 2, 3] return = 2 The values 2 and 4 each appear twice. Because their frequencies tie, return the smaller value, 2.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Build a frequency map in one pass over nums. Then scan the map and track the best value so far. Update when the count is strictly higher, or when the count is equal and the value is smaller. That one condition is the whole trick. The common pitfall is returning the first max you find, or the last one, which depends on iteration order and fails the tie-break. In Example 1, 2 and 4 both appear twice, so the answer is 2. Another option is sorting and counting runs, but that costs O(n log n) when the map is O(n). Watch for negative numbers and an empty array if the constraints allow it. If you freeze under the clock, StealthCoder is the hedge during the live OA. It reads the prompt and hands you the map-plus-tie-break solution so you can type it with confidence.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Most Frequent Integer with Smaller Tie-Break cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass ByteDance's OA.
ByteDance reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Most Frequent Integer with Smaller Tie-Break FAQ
How hard is the ByteDance most frequent integer question really?+
Easy. It's a frequency count with one extra rule. Most candidates know the hash map part. The only real risk is mishandling the tie-break, so test it with a case where two values share the top count.
What's the trick to the tie-break?+
Compare both count and value. Replace your current answer if the new count is greater, or if the counts match and the new value is smaller. That single condition handles every tie, no matter how the map iterates.
What time complexity should I aim for?+
O(n) time and O(k) space, where k is the number of distinct values. One pass builds the counts and one pass over the map picks the answer. Sorting works but is slower than it needs to be.
Can I solve it without a hash map?+
Yes. Sort the array and count consecutive runs, keeping the longest run. Because the array is sorted, the first value to reach the max run is already the smallest. It costs O(n log n), so the map is usually better.
How do I prepare for this in 48 hours?+
Write the solution twice from scratch in your language of choice. Then test four cases: a clear winner, a tie, all identical values, and negative numbers. That covers nearly everything this problem can throw at you.