Dsa
Trees
Medium
Inverted Leaf Count
Count the number of leaf nodes in a binary tree after inverting it. Inversion is defined as swapping the left and right children of every node. You will receive input in the same format as the previous problems, starting with the number of nodes followed by the node values in level order. The output should be a single integer representing the number of leaf nodes in the inverted tree.
Example Input:
7
1
2
3
4
null
null
5
6
null
null
null
Example Output:
4
Key concepts
treesleavesinversion
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now