240 发简信
IP属地:加州
  • 关于不用全局变量:

    自建一个class,包含四个元素,节点指针,和,总数,平均数。

    自建一个priorityQ,排序自定义class,比较class中的平均数,从大到小排列。

    所有节点全部回传class,节点遍历子节点,获得所有子节点的class,求和并更新自己的class。如果该节点不是叶子(子节点列表长度为0),把自己的class加入到PQ中。

    最后根函数poll PQ的第一个class,并返回他的node指针。


    不知道这样有什么问题,确实挺耗费内存的。 :smiley:

    平均数最大子树

    http://www.1point3acres.com/bbs/forum.php?mod=viewthread&tid=203052&extra=page%3D1%26fi...

  • public class PathSum {
    public int Solution(TreeNode root) {
    if (root == null) return 0;
    return Math.min(Solution(root.left), Solution(root.right)) + root.val;
    }
    }

    中间两个判断多余了吧

    BST Minimum Path Sum

    跟BST没啥关系,不要看到BST就以为是最左边的路径之和(左边路径可以很长,右边路径可以很短),用递归做很简单。 来源:http://wdxtub.com/interview...

  • public boolean isRS(String a, String b){

    return (a.length() == b.length()) && ((a+a).indexOf(b) != -1);
    }

    Rotate String

    题目 Given two words, find if second word is the round rotation of first word.For example...