摘要:
此题如果 #1 和 #4判断分支交换,大集合就会超时(因为每次对于非叶子节点都要判断是不是叶子节点)。可见,有时候if else判断语句也会对于运行时间有较大的影响。import java.util.ArrayList;class TreeNode { int val; TreeNode left; TreeNode right; TreeNode(int x) { val = x; }}public class Solution { private int currSum = 0; private ArrayList> result = new Array... 阅读全文
posted @ 2013-07-23 14:54
kkmm
阅读(861)
评论(0)
推荐(0)
摘要:
很简单一道题,搞错了N次,记录一下。public class Solution { private int currSum = 0; public boolean hasPathSum(TreeNode root, int sum) { if (null == root) return false; currSum = 0; return hasPathSumCore(root, sum); } public boolean hasPathSumCore(TreeNode r... 阅读全文
posted @ 2013-07-23 14:17
kkmm
阅读(421)
评论(0)
推荐(0)
摘要:
class ListNode { int val; ListNode next; ListNode(int x) { val = x; next = null; }}public class Solution { private ListNode left; //java不支持c++的LinkedList &*p这种方式,所以用member variable来存放left private boolean alreadyDone = false; public void reverseLinkedList... 阅读全文
posted @ 2013-07-23 11:10
kkmm
阅读(979)
评论(0)
推荐(0)
浙公网安备 33010602011771号