← All problemsSign in

3319. K-th Largest Perfect Subtree Size in Binary Tree

LeetCodeTreeDepth-First SearchSortingBinary TreeOpen on judge ↗

You are given the root of a binary tree and an integer k. Return an integer denoting the size of the kth largest perfect binary subtree, or -1 if it doesn't exist. A perfect binary tree is a tree where all leaves are on the same level, and every parent has two children. Example 1: Input: root = [5,3,6,5,2,5,7,1,8,null,null,6,8], k = 2 Output: 3 Explanation: The roots of the perfect binary

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start