Longest Concatenation of Short Tags With No Repeated Letters
Last updated: November 29, 2026
Quick Overview
Given a list of short lowercase tags, choose a subsequence of them to concatenate so that the result has no repeated letter. Return the maximum possible length.
0
0
0 solved
Given a list of short lowercase tags, choose a subsequence of them to concatenate so that the result has no repeated letter. Return the maximum possible length.
A Google technical screen that rewards representing each candidate as a 26-bit mask. The interviewer checks that you discard tags with internal repeats, use bitwise AND for conflict checks, and explain the subset search bound.
What the Interviewer Expects
- Converts each tag to a 26-bit mask and drops tags with repeated letters
- Uses mask & chosen == 0 to test compatibility in O(1)
- Backtracks over include/exclude decisions
- Prunes when the remaining tags cannot beat the best
- Notes the answer is capped at 26
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you return the chosen tags?
- How would you solve it if tags can be reordered and reused?
- What if the limit were k repeats of each letter instead of one?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input: list of up to 16 tags, each up to 26 lowercase letters.
- Output: maximum length of a concatenation of some tags (order irrelevant to the answer) with all letters distinct.
- Example: `["un",...
High-Level Design
Preprocess: for each tag, build a bitmask; if any letter repeats inside the tag, drop it. Keep pairs (mask, length) and sort by length descending so big tags are tried first.
DFS over index i with ...