@@ -0,0 +1,2339 @@
+package algorithms.problems;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport datastructures.tree.BinaryTree;%0Aimport datastructures.tree.TreeNode;%0A%0Apublic class DeepestNodeBinaryTree %7B%0A%0A  private BinaryTree%3CInteger%3E tree = null;%0A  private Map%3CInteger, TreeNode%3CInteger%3E%3E nodesMap = null;%0A%0A  public DeepestNodeBinaryTree() %7B%0A    tree = new BinaryTree%3CInteger%3E();%0A    nodesMap = new HashMap%3CInteger, TreeNode%3CInteger%3E%3E();%0A  %7D%0A%0A  public void constructTree(String%5B%5D input) %7B%0A    for (String line : input) %7B%0A      String%5B%5D values = line.split(%22 %22);%0A      int val = 0;%0A      switch (values%5B0%5D) %7B%0A      case %22insertRoot%22:%0A        val = Integer.parseInt(values%5B1%5D);%0A        nodesMap.put(val, tree.insertRoot(val));%0A        break;%0A      case %22insertLeft%22:%0A        insert(values%5B1%5D, values%5B2%5D, true);%0A        break;%0A      case %22insertRight%22:%0A        insert(values%5B1%5D, values%5B2%5D, false);%0A        break;%0A      %7D%0A    %7D%0A  %7D%0A%0A  public Integer getDeepestNode() %7B%0A    return deepestNode(tree.getRoot()).treeNode.data;%0A  %7D%0A  %0A  private TreeNodeWrapper%3CInteger%3E deepestNode(TreeNode%3CInteger%3E root) %7B%0A    if(root == null) %7B%0A      return new TreeNodeWrapper%3CInteger%3E(null, -1);%0A    %7D%0A    %0A    TreeNodeWrapper%3CInteger%3E leftWrapper = deepestNode(root.left);%0A    TreeNodeWrapper%3CInteger%3E rightWrapper = deepestNode(root.right);%0A    %0A    if(leftWrapper.treeNode == null && rightWrapper.treeNode == null) %7B%0A      return new TreeNodeWrapper%3CInteger%3E(root, 1);%0A    %7D else %7B%0A      TreeNodeWrapper%3CInteger%3E deepestWrapper = (leftWrapper.depth %3E= rightWrapper.depth) ? leftWrapper : rightWrapper;%0A      deepestWrapper.depth += 1;%0A      return deepestWrapper;%0A    %7D%0A  %7D%0A  %0A  private void insert(String parentStr, String nodeStr, boolean isLeft) %7B%0A    int parentVal = Integer.parseInt(parentStr);%0A    int nodeVal = Integer.parseInt(nodeStr);%0A    TreeNode%3CInteger%3E parentNode = nodesMap.get(parentVal);%0A    if(parentNode == null) %7B%0A      return;%0A    %7D%0A    %0A    TreeNode%3CInteger%3E node = new TreeNode%3CInteger%3E(nodeVal);%0A    nodesMap.put(nodeVal, tree.insert(parentNode, node, isLeft));%0A  %7D%0A  %0A  @SuppressWarnings(%22hiding%22)%0A  private class TreeNodeWrapper%3CInteger%3E %7B%0A    TreeNode%3CInteger%3E treeNode = null;%0A    int depth = 0;%0A    %0A    public TreeNodeWrapper(TreeNode%3CInteger%3E treeNode, int depth) %7B%0A      this.treeNode = treeNode;%0A      this.depth = depth;%0A    %7D%0A  %7D%0A%7D%0A

Add solution for deepest node in a BinaryTree :smile: