Reported August 2024
Uberhash table

Calculate Visited Countries

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 asked this in August 2024 and it's a string/array parsing problem dressed up as travel data. You're given a list of countries visited (likely as strings or a nested structure) and need to count or deduplicate them. The trick is that Uber loves edge cases: null inputs, repeated entries, and formatting variations. If you blank on the approach live, StealthCoder will read the actual input format and guide you to the right data structure. This is not hard, but precision matters.

Pattern and pitfall

The core pattern is hash-table counting or set deduplication. Parse the input (probably a list of country strings), normalize the data (handle case sensitivity, whitespace), then use a hash map to track visits or a set to get unique countries. The catch is always in the details: are there duplicates to ignore? Do you need the count or just the list? Uber's version likely includes a twist like 'return countries visited more than once' or 'handle null/empty gracefully'. Walk through the example first, identify what 'visited' actually means in their schema, then build the solution. If you freeze during the OA, StealthCoder sees the real constraints and flags the right approach instantly.

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 Calculate Visited Countries 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

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as contains duplicate. 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. 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.

Calculate Visited Countries FAQ

Is this actually just counting or deduplicating countries?+

Without the full problem text, assume both are possible. The most common version asks you to return a deduplicated list or count unique visits. Parse the problem statement carefully for the exact return type. If it's ambiguous, ask the proctor for clarification before coding.

What if the input has null or empty values?+

Filter them out. Hash-table problems always test defensive coding. Add a guard clause at the start: if input is null or empty, return an empty result. This shows you think about edge cases and is almost always accepted.

Does case sensitivity matter for country names?+

Probably yes. 'USA' and 'usa' might be different or the same depending on the spec. Check the examples. If unclear, normalize to lowercase or use a set with case-insensitive comparison. Mention your assumption in a comment.

Is this an O(n) problem or do I need sorting?+

Hash-table deduplication is O(n) time and space. You don't need to sort unless the problem explicitly asks for the output in a specific order. If order matters, sort at the end after deduplication.

What if there are duplicate countries in the input?+

Use a set or hash map to track what you've seen. If the problem wants counts, use a map with country as key and visit count as value. If it just wants unique countries, a set is simpler and faster.

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