Search
⌘K

Leetcode 2445. Number of Nodes With Value One

Given a tree (or graph) whose nodes are labeled 0 or 1 and a set of rules/operations that change node values based on ancestors or path flips, determine how many nodes end up with value 1. This typically requires a DFS/BFS that carries a cumulative flip/XOR state (or other propagated state) and careful bookkeeping to apply updates efficiently.

Asked at:

Google

Google


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Mid January, 2025

Google

Google

Mid-level

Number of Islands in a Binary Tree: Given a Binary tree having nodes with value 0 and 1, write a function to return the number of islands

Mid January, 2025

Google

Google

Mid-level

Number of Islands in a Binary Tree: Given a Binary tree having nodes with value 0 and 1, write a function to return the number of islands

Early September, 2024

Google

Google

Mid-level

Given a binary tree with nodes having values 0 and 1, return the number of islands of 1s. An island of 1 is defined as a group of ones surrounded by zeroes or at the boundary of the tree.

Comments

Your account is free and you can post anonymously if you choose.