public static int countPaths(TreeNode root, int S) { // TODO: Write your code here CountAllPathSum CAPS = new CountAllPathSum(); LinkedList <int> list = new LinkedList <int>(); CAPS.Step(root, S, list, list.First); // start with empty list return(CAPS._countPaths); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); TreeNode root = new TreeNode(12); root.left = new TreeNode(7); root.right = new TreeNode(1); root.left.left = new TreeNode(4); root.right.left = new TreeNode(10); root.right.right = new TreeNode(5); Console.WriteLine("Tree has path: " + CountAllPathSum.countPaths(root, 11)); }