PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates a candidate's ability to design efficient lookup and preprocessing data structures for mapping identifiers to bank records, including reasoning about handling missing codes and duplicate entries, relevant to a Machine Learning Engineer role.

  • medium
  • Plaid
  • Coding & Algorithms
  • Machine Learning Engineer

Find Banks From Identifier Mappings

Company: Plaid

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Plaid receives institution metadata from multiple sources. You are given two mappings: 1. `code_to_institution`: a one-to-one mapping from a bank code to a canonical institution ID. 2. `institution_to_banks`: a one-to-many mapping from a canonical institution ID to one or more bank names or bank records. Implement a function that preprocesses these mappings and supports queries of the form: given a bank code, return the corresponding bank or banks. For example: ```text code_to_institution = { "C001": "inst_1", "C002": "inst_2", "C003": "inst_1" } institution_to_banks = { "inst_1": ["Bank A", "Bank A Savings"], "inst_2": ["Bank B"] } ``` Queries: ```text find_banks("C001") -> ["Bank A", "Bank A Savings"] find_banks("C002") -> ["Bank B"] find_banks("UNKNOWN") -> [] ``` Discuss the data structures you would use, the preprocessing time, query time, and how you would handle missing codes or duplicate bank records.

Quick Answer: This question evaluates a candidate's ability to design efficient lookup and preprocessing data structures for mapping identifiers to bank records, including reasoning about handling missing codes and duplicate entries, relevant to a Machine Learning Engineer role.

Plaid receives institution metadata from multiple sources. You are given two mappings: `code_to_institution`, which maps a bank code to a canonical institution ID, and `institution_to_banks`, which maps a canonical institution ID to a list of bank names. Implement `solution(code_to_institution, institution_to_banks, queries)` that preprocesses these mappings and answers all query codes efficiently. For each query code, return the list of bank names for the matching institution. If a bank name appears multiple times for the same institution, include it only once and preserve the order of first appearance. If the code does not exist, or its institution ID does not appear in `institution_to_banks`, return an empty list for that query.

Constraints

  • 0 <= len(code_to_institution), len(institution_to_banks), len(queries) <= 2 * 10^5
  • The total number of bank names across all institution lists is at most 2 * 10^5
  • Codes, institution IDs, and bank names are strings
  • Duplicate bank names may appear in the same institution's list
  • Average-case O(1) hash map lookups are expected

Examples

Input: ({"C001": "inst_1", "C002": "inst_2", "C003": "inst_1"}, {"inst_1": ["Bank A", "Bank A Savings"], "inst_2": ["Bank B"]}, ["C001", "C002", "UNKNOWN", "C003"])

Expected Output: [["Bank A", "Bank A Savings"], ["Bank B"], [], ["Bank A", "Bank A Savings"]]

Explanation: C001 and C003 both map to inst_1, so they return the same bank list. UNKNOWN is not a known code, so it returns an empty list.

Input: ({"X1": "i1", "X2": "i2", "X3": "i_missing"}, {"i1": ["Alpha Bank", "Alpha Bank", "Beta Credit", "Alpha Bank"], "i2": []}, ["X1", "X2", "X3", "NOPE"])

Expected Output: [["Alpha Bank", "Beta Credit"], [], [], []]

Explanation: Duplicate bank names for i1 are removed while preserving order. X3 points to an institution with no bank list, and NOPE is an unknown code.

Input: ({}, {}, ["ANY"])

Expected Output: [[]]

Explanation: With no mappings at all, every query returns an empty list.

Input: ({"A": "inst_single"}, {"inst_single": ["Solo Bank"]}, [])

Expected Output: []

Explanation: If there are no queries, the result is an empty list.

Hints

  1. A bank code does not map directly to banks. First map code -> institution, then institution -> banks.
  2. To remove duplicates while preserving order, keep a `set` of seen bank names and append only the first time you encounter each one.
Last updated: May 23, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Resolve routing-number to bank mapping - Plaid (easy)
  • Design a coupon redemption system - Plaid (Medium)
  • Compute discounted prices in a queue - Plaid (Medium)