← Microsoft questions

Subtree Check

Filed under Microsoft

Given the roots of two binary trees, root and subRoot, check if subRoot is a subtree of root. If it is true, return the total number of nodes in the subRoot tree; otherwise, return -1.

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Microsoft questions

Collected from public candidate posts and coding forums. Updated Nov 2026.