Reported February 2023
Bloombergarray

Count Teams Outscoring a Target Team

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

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

Bloomberg reportedly served this one in February 2023, and the input size is the first thing to check. Every team plays exactly one match, so the data is one pass wide, and anything that compares every team to every other team is wasted work. You get matches, scores, and a target team, and you count teams that scored strictly more than the target. It's a hash map and a single scan. The trap is small and easy to miss. If you blank on the setup during the OA, StealthCoder can sit invisibly on your screen as a safety net, but this one is simple enough to own.

The problem

matches[i] = [homeTeam, awayTeam] and scores[i] = [homeGoals, awayGoals]. Every team appears in exactly one match.
Return how many teams scored strictly more goals than targetTeam.

Function
countTeamsOutscoring(matches: String[][], scores: int[][], targetTeam: String) → int

Examples
Example 1
matches = [["Red","Blue"],["Green","Yellow"],["Orange","Violet"]]
scores = [[0,1],[2,5],[0,0]]
targetTeam = "Blue"
return = 2
Blue scored one; Green and Yellow scored more.

Constraints
Match and score arrays have equal length.
The target team appears exactly once.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is to separate finding the target's goals from counting teams above it. Walk the matches once. For each index i, home goals are scores[i][0] and away goals are scores[i][1]. When you see targetTeam as home or away, store its goals. Then do a second pass and count every team whose goals are strictly greater. Every team appears exactly once, so you don't need a map of totals, and you never need nested loops. That's O(n) time and O(1) extra space. The common pitfall is using >= instead of >, which wrongly counts ties, including the target itself. Another is counting per match instead of per team, so a match where both sides beat the target counts as 2, not 1. Check Example 1: Blue scored 1, Green scored 2 and Yellow scored 5, Orange and Violet scored 0. That gives 2 only if you count teams and skip the 0-0 match. If you freeze live, StealthCoder is the hedge that reads the prompt and hands you this scan.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Count Teams Outscoring a Target Team 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 for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Bloomberg reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Count Teams Outscoring a Target Team FAQ

How hard is this Bloomberg OA question really?+

Easy. It's an array scan with one comparison. The difficulty is reading carefully, not the algorithm. Most misses come from counting matches instead of teams, or using >= instead of strict greater. If you can write two loops and an if, you can solve it.

What's the trick to avoid brute force?+

Find the target's goals in one pass, then count every team scoring strictly more in another. Each team appears once, so there's no need to aggregate or compare pairs. That keeps it O(n) instead of O(n^2).

Do I need a hash map for this problem?+

Not really. Every team appears in exactly one match, so you don't sum anything per team. You only need the target's goal count, stored in a single integer. A map adds code without adding value here.

What edge cases should I test before submitting?+

Test the target being the home team and the away team. Test ties, which must not count. Test a 0-0 match, and a case where both teams in a match beat the target, so you count 2 from that one match.

How do I prepare for this in 48 hours?+

Practice array scans with a stored reference value, then a count with a strict comparison. Write the solution by hand once, using the Blue example. Spend remaining time on the Bloomberg-style phrasing, where the statement is short and the details matter.

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

OA at Bloomberg?
Invisible during screen share
Get it