Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions algorithm-learning-common/target/classes/log4j2.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.example.ilene;

import com.example.common.TemplateCallBack;
import com.example.common.TreeNode;
import lombok.extern.slf4j.Slf4j;
import junit.framework.Assert;


/**
* 543. ��������ֱ��
* ����һ�ö�����������Ҫ��������ֱ�����ȡ�һ�ö�������ֱ�������������������·�������е����ֵ������·�����ܴ���Ҳ���ܲ���������㡣
*/
@Slf4j
public class DiameterofBinaryTree implements TemplateCallBack {
int ans = 0;
public int diameterOfBinaryTree(TreeNode root) {
sideDepth(root);
return ans;
}

public int sideDepth(TreeNode root){
if (root == null){
return 0;
}

int leftDepth = sideDepth(root.left);
int rightDepth = sideDepth(root.right);
ans = Math.max(ans, leftDepth+rightDepth);
return Math.max(leftDepth, rightDepth)+1;

}
TreeNode root1;
@Override
public void generateCase() {
Integer[] case1 = new Integer[]{1, 2, 3, 4, 5};
root1 = TreeNode.getInstance(case1);
}

@Override
public void run() {
Assert.assertEquals(3, sideDepth(root1));
}
}
14 changes: 0 additions & 14 deletions algorithm-learning-loorr/target/classes/log4j2.xml

This file was deleted.