gelita

Find Longest Path in Binary Tree

Mar 16th, 2020
716
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.17 KB | None | 0 0
  1. private int findLongestPath(root){
  2.     if(root == null){
  3.       return 0;
  4.     }
  5.     return Math.max(findLongestPath(root.left), findLongestPath(root.right)) +1;
  6.   }
  7. }
Advertisement
Add Comment
Please, Sign In to add comment