Implement Multiple Interview Coding Tasks
Company: Atlassian
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
Across several coding rounds, the following independent algorithm and data-structure problems were reported:
1. **Simplified line formatter**: Given a list of words and an integer `maxWidth`, greedily pack words into lines. For any line with at least two words, insert hyphens `-` between adjacent words so that the total line length becomes exactly `maxWidth`. Distribute any extra hyphens from left to right. If a line contains only one word, leave it unchanged even if it is shorter than `maxWidth`.
2. **Connection threshold tracker**: You are given a sequence of events of the form `[action, userA, userB]`, where `action` is either `connect` or `disconnect`. Treat connections as undirected. Ignore duplicate connects and invalid disconnects. After processing all events, return two sets of users: those with fewer than `n` active connections, and those with at least `n` active connections.
3. **Movie recommendation from similar viewers**: You are given rating records of the form `[userId, movieId, rating]` and a target user. Define a similar user as someone who has watched at least one movie also watched by the target user. Recommend every movie that the target user has not watched and that at least one similar user rated `4` or `5`. Return distinct movie IDs.
4. **Path router with wildcard support**: Implement `add(path, value)` and `get(path)`. Paths are slash-delimited strings such as `/bar/test/foo`. Support patterns containing `*`, where `*` matches exactly one path segment. Exact matches take priority over wildcard matches. If no route matches, return `null`.
5. **Constant-time key counter**: Design a data structure that supports `inc(key)`, `dec(key)`, `getMaxKey()`, and `getMinKey()` in constant time.
Quick Answer: This multi-part prompt evaluates algorithmic problem-solving and data structure design skills across string processing and greedy formatting, dynamic graph/connectivity tracking, collaborative-filtering style recommendation logic, pattern-based routing with wildcards, and constant-time key-count data structures.