Flag Pin Hashtags That Start With a Blocked Prefix

Last updated: November 29, 2026

Quick Overview

Trust and safety maintains a list of blocked hashtag prefixes. Given the hashtags on incoming Pins, return those that start with any blocked prefix, case-insensitively, keeping input order.

Pinterest
Coding & Algorithms
Software Engineer
Pinterest
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Easy

0

0

0 solved


Trust and safety maintains a list of blocked hashtag prefixes. Given the hashtags on incoming Pins, return those that start with any blocked prefix, case-insensitively, keeping input order.

Spam rings on Pinterest often rotate hashtags around a fixed stem, so prefix blocking is a cheap first filter in the content safety pipeline. Online assessments use this to check you know when a trie beats checking every prefix with startswith.

What the Interviewer Expects
  • Builds a trie from blocked prefixes
  • Stops scanning a tag at the first terminal node or missing child
  • Applies case folding consistently on both sides
  • Compares trie cost to the naive tags times prefixes approach
  • Keeps output in input order
Key Topics to Cover
tries
prefix matching
content safety
string processing
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 also support blocked substrings anywhere in the tag?
  • How would you update the blocklist without rebuilding the trie under live traffic?
  • How would you avoid blocking legitimate tags like #spa when the stem is #spam?
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
  • Inputs: list of tags, list of blocked prefixes. Matching is case-insensitive.
  • Output: tags with any blocked prefix, original casing, input order....
High-Level Design

Insert every prefix into a trie and mark terminal nodes. For each tag, walk the trie character by character; the first terminal node means a blocked prefix matched, and a missing child means no prefix...


Submit Your Answer
Markdown supported