Reported September 2026
Capital Onearray

Compare Counts Around Pivot

Reported by candidates from Capital One's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Capital One OA. Under 2s to a working solution.
Founder's read

The note on this Capital One question says O(n^2) is fine, so brute force won't get you killed. That's the tell: this is an easy one, reported in September 2026. You get an array and a pivot, count what's strictly above and strictly below, then return "greater", "smaller", or "tie". No tricks in the setup. The risk is rushing and fumbling the strict comparisons or the return strings. If you blank on the live OA, StealthCoder runs invisibly on your desktop and hands you the solution as a safety net. Most people won't need it here.

The problem

You are given an array of integers numbers and an integer pivot. Let countGreater denote how many integers within numbers are strictly greater than pivot, and countLess denote how many integers are strictly less than pivot.
Your task is to compute countGreater and countLess, then return:
"greater" if countGreater is greater than countLess;
"smaller" if countGreater is less than countLess;
"tie" if they are equal.
Note: You are not expected to provide the most optimal solution, but a solution with time complexity not worse than O(numbers.length^2) will fit within the execution time limit.

Function
solution(numbers: int[], pivot: int) → String

Examples
Example 1
numbers = [1, 3, 0, -1, 1, 4, 3]
pivot = 2
return = "smaller"
There are countGreater = 3 integers greater than pivot = 2. The integers less than 2 are 1, 0, -1, and 1, so countLess = 4. Since countGreater is less than countLess, the result is "smaller".

Reported by candidates. Source: FastPrep

Pattern and pitfall

One pass does it. Keep two counters, countGreater and countLess. For each number, if it's greater than pivot, bump one. If it's less, bump the other. Values equal to pivot get ignored, and that's the main pitfall. Don't use >= or <= by accident. Compare the counters at the end and return the matching string. That's O(n) time and O(1) space, well inside the stated O(n^2) allowance. Another pitfall is the exact output strings: lowercase "greater", "smaller", and "tie". Example 1 is worth tracing by hand: 3 above 2, 4 below, so "smaller". You can also use one running difference counter, adding 1 for greater and subtracting 1 for less, then check its sign. If your head goes blank mid-assessment, StealthCoder is the hedge that gives you this loop in seconds. The logic is simple enough that careful reading beats cleverness.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Compare Counts Around Pivot 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. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Capital One's OA.

Capital One reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Compare Counts Around Pivot FAQ

How hard is the Capital One Compare Counts Around Pivot question really?+

It's easy. One loop, two counters, one comparison. The note says even O(n^2) fits, so nobody expects cleverness. The only way to fail is sloppy edge handling, like counting values equal to pivot or returning the wrong string casing.

What's the trick to this problem?+

There isn't one. Count values strictly greater than pivot and strictly less than pivot, and skip equal values. Then compare the two counts. A single signed counter works too: add one for greater, subtract one for less, and check the sign.

Do I need a hash map or sorting?+

No. Sorting costs O(n log n) and adds nothing. A hash map is pointless since you only need two totals. A plain linear scan is the cleanest and fastest answer, with constant extra space.

What edge cases should I test?+

Test an empty-ish case if allowed, an array where every value equals pivot (should return "tie"), all values above, all below, and negatives. Example 1 gives "smaller" with 3 greater and 4 less, so run that too.

How do I prepare in 48 hours for this kind of OA?+

Practice writing simple counting loops cleanly and fast. Read the prompt twice for strict versus non-strict comparisons and exact output strings. Then spend leftover time on medium array and hash map problems, since the rest of the assessment may be harder than this one.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Capital One.

OA at Capital One?
Invisible during screen share
Get it