![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Divide and Conquer
再见小小ronnie
这个作者很懒,什么都没留下…
展开
-
Leetcode 50. Pow(x, n)
Divide and conquer. public class Solution { public double myPow(double x, int n) { if (n == 0) return 1; double half = myPow(x, n/2); if (n%2 == 0) return half * half;原创 2017-01-26 12:44:00 · 130 阅读 · 0 评论 -
Leetcode 378. Kth Smallest Element in a Sorted Matrix
O(mlogn), m is number of columns and n is number of rows. O(m*n) space. Merge the matrix into an array, return kth element. public class Solution { public int kthSmallest(int[][] matrix, int k)原创 2017-03-10 11:58:48 · 228 阅读 · 0 评论 -
Leetcode 23. Merge k Sorted Lists
Given a list array, for example, l1 l2 l3 l4 l5 l6 l7 l8. Intuitive solution, merge l1 and l2 into new list l1', then merge l1' and l3 into l2', similarly, merge l2' and l4 into l3'. Time complexity原创 2017-03-10 03:47:53 · 211 阅读 · 0 评论