有搞GPU computing的吗# PhotoGear - 摄影器材
t*i
1 楼
http://oj.leetcode.com/problems/minimum-depth-of-binary-tree/
/**
* Definition for binary tree
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
public class Solution {
public int minDepth(TreeNode root) {
getMinDepth(root, 0);
return min;
}
public static int min = Integer.MAX_VALUE;
public void getMinDepth(TreeNode node, int level) {
if (node == null) {
if (min > level)
min = level;
return;
} else {
getMinDepth(node.left, level + 1);
getMinDepth(node.right, level + 1);
}
}
}
Submission Result: Wrong Answer
Input: {0}
Output: 0
Expected: 1
请教一下为啥OJ的结果是0..
/**
* Definition for binary tree
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
public class Solution {
public int minDepth(TreeNode root) {
getMinDepth(root, 0);
return min;
}
public static int min = Integer.MAX_VALUE;
public void getMinDepth(TreeNode node, int level) {
if (node == null) {
if (min > level)
min = level;
return;
} else {
getMinDepth(node.left, level + 1);
getMinDepth(node.right, level + 1);
}
}
}
Submission Result: Wrong Answer
Input: {0}
Output: 0
Expected: 1
请教一下为啥OJ的结果是0..