Match Abbreviated CamelCase Queries Against Class Names

Last updated: November 29, 2026

Quick Overview

Given a list of class names and a pattern such as "FoBa", return which names match: the pattern's characters must appear in order, and any extra characters inserted must be lowercase.

Google
Coding & Algorithms
Software Engineer
Google
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Medium

0

0

0 solved


Given a list of class names and a pattern such as "FoBa", return which names match: the pattern's characters must appear in order, and any extra characters inserted must be lowercase.

A Google phone screen question framed around IDE or Code Search jump-to-class, where typing capitals finds `FooBarService`. The interviewer checks two-pointer matching and, at scale, a trie of names that prunes on uppercase mismatches.

What the Interviewer Expects
  • Define the match rule precisely: extra letters must be lowercase
  • Implement a clean two-pointer check per name
  • Reject names with an unmatched uppercase letter
  • Discuss a trie over names to share work across many names
  • Handle patterns containing lowercase letters
Key Topics to Cover
two pointers
trie
pattern matching
camel case
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you rank matches, for example by the fewest inserted characters?
  • How would you index a million class names for this kind of query?
  • What if digits and underscores can appear in names?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: names, a list of identifiers, and pattern. Output: a list of booleans, one per name, True when name can be formed by inserting only lowercase letters into pattern at any positions....

High-Level Design

For a single name, scan its characters with a pointer j into the pattern. If name[i] == pattern[j], advance j. Otherwise the character is an insertion and must be lowercase; an uppercase inserti...


Submit Your Answer
Markdown supported