← Microsoft questions

Check if tree t2 is a subtree of t1 and return its size

Filed under Microsoft

Given two binary trees t1 and t2, check if t2 is a subtree of t1. If it is, return the total number of nodes in t2; 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.