GoLang Solution For LeetCode Problem: Binary Tree Cameras
Solving Binary Tree Cameras in go. Please try yourself first to solve the problem and submit your implementation to LeetCode before looking into solution.
Given a binary tree, we install cameras on the nodes of the tree.
Calculate the minimum number of cameras needed to monitor all nodes of the tree.
Input: [0,0,null,0,0] Output: 1 Explanation: One camera is enough to monitor all nodes if placed as shown.
Input: [0,0,null,0,null,0,null,null,0] Output: 2 Explanation: At least two cameras are needed to monitor all nodes of the tree. The above image shows one of the valid configurations of camera placement.
See the full details of the problem Binary Tree Cameras at LeetCode
Originally posted at: @github.com/halfrost/LeetCode-Go