← Lead Bank Interview Insights

Lead Bank·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Coding round at Lead Bank for a software engineer role. One problem, but it had enough layers to keep me busy for a while.

Questions Asked (1)

Q1

You're given a dataset of edges representing like counts between pairs of users. Implement two things: (a) a lookup that returns the like count between any two users, and (b) a friend recommendation system. The recommendation logic goes like this: find who the target user likes most, then recommend that person's most-liked user. A recommended user can't be the target user themselves, and can't already be a mutual friend. Ties are possible, and if no valid recommendation exists among the top candidates you fall back to the next tier, throwing an error only if nothing works.

Algorithms & Data Structures
Author's notes

The lookup part was fine, basically just a map keyed on user pairs.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the data model and constraints, then design a hash map for O(1) like count lookups and a recommendation algorithm that handles ties and fallback tiers. Walk through the algorithm step-by-step, discussing edge cases and complexity, and finally test with examples.

Pro tip: Explicitly discuss how you handle ties and fallback tiers, as this demonstrates attention to detail and robustness. Also, mention that you would confirm whether the graph is directed and whether 'mutual friend' means both users like each other.

1. Clarify requirements and data model

Ask whether the graph is directed (i.e., like counts are asymmetric) and define 'mutual friend' as a pair where both users have a like count > 0 between them. Confirm that the recommendation should be based on the target user's most-liked user, then that user's most-liked user.

2. Design the lookup structure

Use a hash map with a composite key (e.g., tuple of user IDs) to store like counts, enabling O(1) average-time lookup. Alternatively, use a nested hash map (user -> {other_user: count}) for efficient access.

3. Implement the recommendation algorithm

Find the target user's most-liked user (max like count). If ties, consider all top candidates. For each candidate, find their most-liked user (again handling ties). Filter out the target user and mutual friends. If no valid recommendation, fall back to the next tier of candidates (e.g., second most-liked user of target, then their top choices, etc.).

4. Handle edge cases and errors

If no valid recommendation exists after exploring all tiers, throw an error. Also handle cases where the target user has no outgoing likes or the candidate has no outgoing likes.

5. Analyze complexity and test

Discuss time and space complexity: lookup is O(1), recommendation may be O(k * m) where k is number of tiers and m is average out-degree. Provide test cases covering ties, fallbacks, and no recommendation.

Key Points to Mention

  • Use of hash maps for O(1) like count lookup
  • Directed graph assumption and definition of mutual friend
  • Tie-breaking strategy: consider all top candidates and fallback tiers
  • Filtering criteria: exclude target user and mutual friends
  • Error handling when no valid recommendation exists
  • Time and space complexity analysis

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.