Given two sorted integer arrays A and B, merge B into A as one sorted array.
Note:
You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements fro...
分类:
其他好文 时间:
2015-01-08 09:43:18
阅读次数:
169
The problem:Convert Sorted List to Binary Search TreeLink:https://oj.leetcode.com/problems/convert-sorted-list-to-binary-search-tree/My analysis:The i...
分类:
其他好文 时间:
2015-01-08 02:02:08
阅读次数:
179
The problem:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.My analysis:The recursion is the best way...
分类:
其他好文 时间:
2015-01-08 00:49:30
阅读次数:
265
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time
complexity should be O(log (m+n)).
分析
这是一道非常经典的题。这题更通用的形式是,给定两个已经排序...
分类:
其他好文 时间:
2015-01-07 23:39:15
阅读次数:
345
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3-...
分类:
其他好文 时间:
2015-01-07 23:25:52
阅读次数:
112
对于两个数组的折半查找public class Solution { public double findMedianSortedArrays(int A[], int B[]) { int m = A.length, n = B.length; if (n == ...
分类:
其他好文 时间:
2015-01-07 22:00:34
阅读次数:
183
【算法思路】利用折半查找的思路去查找这个最小元素
【编程步骤】
* 1. 如果数组num只有一个元素,则所求的最小的元素就是它了;
* 2. 若left到right位置的元素严格递增,则最小的元素为num[left],如左图
否则,如右图,利用折半查找,若left到mid递增有序,则最小元素必出现在右边部分:mid+1到right;
若mid到right递增有序,则最小元素出现在左边部分:left到mid;
while(left<right){
if(num[left]<num...
分类:
其他好文 时间:
2015-01-07 16:55:49
阅读次数:
171
The problem:Sort a linked list inO(nlogn) time using constant space complexity.My analysis:The is problem could be elegantly solved by using merge.The...
分类:
其他好文 时间:
2015-01-07 01:50:28
阅读次数:
112
Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =[1,1,1,2,2,3],Your function should ret...
分类:
其他好文 时间:
2015-01-07 00:23:00
阅读次数:
245
【题目】
Merge k sorted
linked lists and return it as one sorted list. Analyze and describe its complexity.
【分析】
无
【代码】
/*********************************
* 日期:2015-01-06
* 作者:SJF0115
* 题目:...
分类:
其他好文 时间:
2015-01-06 23:10:50
阅读次数:
202