分治
sjphiChina
代码是最为耐心、最能忍耐和最令人愉快的伙伴,在任何艰难困苦的时刻,它都不会抛弃你。
展开
-
Merge k Sorted Lists
基本功中的基本功。所以还忘了最开始的错误检测!!!!!!/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */public class Sol原创 2016-06-24 22:23:15 · 200 阅读 · 0 评论 -
Different Ways to Add Parentheses
把数字用符号隔开,用分治法求出所有可能。public class Solution { public List diffWaysToCompute(String input) { List result = new LinkedList<>(); for (int i = 0; i < input.length(); i++) {原创 2016-06-23 12:18:56 · 185 阅读 · 0 评论 -
Count Univalue Subtrees
参考:点击打开链接/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class S原创 2016-06-23 14:06:47 · 382 阅读 · 0 评论