Check Whether a Template Occurs in Leaf Text of a Binary Tree

Asked at Google · Coding Questions · Difficulty: Medium · Last asked Jul 19, 2026

Given a binary tree whose leaves store characters (including possible spaces) and whose internal nodes store no text, visit leaves from left to right and concatenate their characters into a string `S`.

Loading the problem…