Tap here to switch tabs
Problem
Submissions

Problem: Count Complete Tree Nodes

med
30 min
Try to solve the Count Complete Tree Nodes problem.

Statement

Given the root node root of a complete binary tree, return the total number of nodes in the tree.

A complete binary tree is a binary tree where every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible.

Note: The input tree is guaranteed to be complete.

Constraints:

  • The number of nodes in the tree is in the range [0,5104][0, 5 \cdot 10^4].

  • 00 \leq Node.val 5104\leq 5 \cdot 10^4.

  • The tree is complete.

Tap here to switch tabs
Problem
Submissions

Problem: Count Complete Tree Nodes

med
30 min
Try to solve the Count Complete Tree Nodes problem.

Statement

Given the root node root of a complete binary tree, return the total number of nodes in the tree.

A complete binary tree is a binary tree where every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible.

Note: The input tree is guaranteed to be complete.

Constraints:

  • The number of nodes in the tree is in the range [0,5104][0, 5 \cdot 10^4].

  • 00 \leq Node.val 5104\leq 5 \cdot 10^4.

  • The tree is complete.