LinkedInMachine Learning Engineer · Take-home ProjectCodemia practiceGreedy on binary tree
Given a binary tree, implement a greedy algorithm to find the maximum sum of non-adjacent nodes. You need to return the maximum sum that can be obtained by selecting nodes such that no two selected nodes are direct parent-child pairs. The input will be the root node of the binary tree, and the output should be an integer representing the maximum sum.