Policy Alias Match Monitor
Preview mode. Log in to edit, run, submit, and save progress.
Policy Alias Match Monitor
A policy scanner searches an incident feed for a short template. A template character can match the same character in the feed, or it can match one of its approved replacement characters. Each mapping describes one allowed replacement from a template character to a feed character. Replacements are checked per character position. The template must match one contiguous substring of the feed. Input Format: You are given strings source and pattern, and an array mappings where each mapping is [from, to]. Output Format: Return true if pattern can match any contiguous substring of source using the allowed replacements, otherwise return false.
Examples
source = "foolproof" pattern = "leet" mappings = [["l","f"],["e","o"],["e","o"],["t","l"]]
YES
Explanation: Substring "fool" matches "leet" using l->f, e->o, e->o, t->l. Therefore the output is YES.
Approach hint
Store allowed conversions in a constant-time lookup table.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.