Reported August 2024
Ubercounting

Count Good Array

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

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

Uber's Count Good Array hit the board in August 2024, and it's a counting problem dressed up as an array task. You're likely given an array and asked to count subarrays or elements meeting some condition. The trick is recognizing that brute force fails at scale. Most candidates start iterating through every possible subarray, then realize the time limit laughs at them. StealthCoder sits invisibly during your OA and feeds you the optimization pattern the moment you start typing the naive solution.

Pattern and pitfall

This is a prefix sum or two-pointer counting problem in disguise. The 'good array' definition matters: you need to understand what makes an element or subarray 'good', then count efficiently. The pitfall is O(n^2) or worse when O(n) or O(n log n) exists. If the condition is cumulative (like sum-based), precompute a prefix array and iterate once. If it's element-level with constraints, hash-table lookups during a single pass win. The live OA pressure makes you skip the optimization step. That's where the hedge kicks in.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Count Good Array 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 StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as count subarrays with score less than k. If you have time before the OA, drill that.

⏵ The honest play

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

Uber 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.

Count Good Array FAQ

What does 'good' mean in this problem?+

Without the full text, 'good' likely refers to a condition on subarray sums, element values, or parity patterns. Read the definition twice before coding. The OA statement is usually buried in a paragraph. Extract it, restate it aloud, then code.

Will brute force time out?+

Almost certainly. If you're iterating all pairs of indices, you're O(n^2) minimum. Uber's constraints usually push n above 10^5. You need prefix sums, hashing, or two pointers to land under 1 second.

Is this a sliding window problem?+

Possibly, if the 'good' condition is about consecutive elements or a range property. Sliding window works when the window's validity is monotonic. If expanding the window makes it invalid, you can shrink from the left to re-validate. Test this assumption first.

Should I use a hash table?+

Yes, if you're counting occurrences of a derived value (like prefix sum differences) and looking for matches. Store cumulative sums as you iterate, then query the table to count prior states that satisfy the 'good' condition.

How much time do I have to solve this live?+

Uber OAs typically give 15-45 minutes per problem depending on the round. Budget 5 minutes to parse the definition, 10 to code, 5 to test edge cases (empty array, single element, all good, none good). Start coding before overthinking.

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

OA at Uber?
Invisible during screen share
Get it