MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / diameterOfBinaryTree

Method diameterOfBinaryTree

TreeDiameter.java:3–10  ·  view source on GitHub ↗
(TreeNode root)

Source from the content-addressed store, hash-verified

1class Solution {
2 int maxi=0;
3 public int diameterOfBinaryTree(TreeNode root) {
4
5 if(root == null) return 0;
6 int ans[]=new int[1];
7 findDiameter(root,ans);
8 return ans[0];
9
10 }
11 public int findDiameter(TreeNode root, int maxi[])
12 {
13 if(root == null) return 0;

Callers

nothing calls this directly

Calls 1

findDiameterMethod · 0.95

Tested by

no test coverage detected