Live Batches
Masterclasses
Menu
Free Courses
Account
Login / Sign Up
Problem Submissions Solution

Count Nodes in Binary Tree

Difficulty: Medium

Acceptance: 64.00%

Points: 30.00

Given the root of a binary tree, return the total number of nodes in the tree. Each node in the tree contains a value and may have a left child, a right child, or both. The task is to count all nodes present in the tree, including the root.

Topics

Companies

Articles

Examples:

N/A

Constraints:
  • 0 = number of nodes = 105
  • -104 = Node.val = 104
Companies:
Microsoft Apple
Topics:
Recursion
Locked Content
Access Restricted: Please Login to access the code editor and test cases.