Python Coding
An analyst's coding round is not a 300-line Leetcode problem but short tasks in plain Python: count, filter, group, estimate complexity. What is tested is whether you can walk a list in one pass, pick the right data structure (dict, set), and state your solution's Big-O aloud.
The traps here are small but expensive: > where >= is needed; a denominator that dropped its zero users; a "largest product" where two negatives make a positive. Below are the eight techniques that make up almost every such task, from a single array scan to dynamic programming.
Topic map
- Complexity (Big-O) — the language for how time and memory grow with input size.
- Array scan — one linear pass checking neighbours instead of sorting or nested loops.
- List aggregation —
sum/countby condition, booleans as 0/1, and the>=threshold trap. - Divisibility and remainder — the
%operator, testing both directions, and guarding against division by zero. - Digit properties — decomposing a number into digits and a per-digit predicate, not a whole-number one.
- Grouping with a dict — bucketing by a canonical signature key instead of pairwise comparison.
- The ARPU metric — total value over user count, and the denominator trap.
- Dynamic programming — the take-or-skip recurrence with rolling state.
Common traps
| Mistake | Consequence |
|---|---|
> instead of >= in a threshold count | Elements exactly equal to the threshold are lost |
| Excluding zero-value users from the ARPU denominator | Inflated average revenue — that is ARPPU, not ARPU |
| "Largest product" = only the two largest | Two large negatives give a larger positive result |
Reading "honestly even" as value % 2 == 0 | You must check every digit, not the whole number's parity |
| Grouping anagrams by length or first letter | Collisions — unrelated words land in one bucket |
| Greedily taking the largest houses in the non-adjacent task | Greedy is suboptimal — you need the take-or-skip recurrence |
Interview relevance
What is watched here is not exotic algorithms but tidiness and a complexity vocabulary. A candidate who writes a one-pass solution and immediately says "this is O(n) time, O(1) space, because..." passes the round even if the syntax is imperfect.
Typical checks:
- Whether you can manage with one linear pass where a beginner reaches for a sort or a nested loop.
- Whether you know your solution's Big-O and grasp the difference between O(n) and O(n log n).
- Whether you catch edge cases — empty list, zero, ties, negatives.
- Whether you pick the data structure for the job — a dict for grouping, a set for fast membership.
Common wrong answer: solving the task "head-on" in O(n²) and not noticing the same result is reachable in one pass — or naming a complexity at random without tying it to the number of passes over the data.