Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target value t...
分类:
编程语言 时间:
2015-03-10 13:40:27
阅读次数:
144
题目:
Merge k sorted
linked lists and return it as one sorted list. Analyze and describe its complexity.
思路:
解法一:维护一个大小为k的堆,每次去堆顶的最小元素放到结果中,然后读取该元素的下一个元素放入堆中,重新维护好。因为每个链表是有序的,每次又是去当前k个元素中最小的,...
分类:
其他好文 时间:
2015-03-09 22:32:10
阅读次数:
203
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.知识点:二叉搜素树: 1. 如果root有左子节点,则所有左边的节点root; 3. root.lef.....
分类:
其他好文 时间:
2015-03-09 20:48:13
阅读次数:
182
题目要求:Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a functi...
分类:
其他好文 时间:
2015-03-09 20:36:53
阅读次数:
163
题目要求:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target va...
分类:
其他好文 时间:
2015-03-09 18:57:19
阅读次数:
186
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 ...
分类:
其他好文 时间:
2015-03-09 15:52:47
阅读次数:
92
Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from l...
分类:
其他好文 时间:
2015-03-09 14:09:06
阅读次数:
151
题目链接:https://leetcode.com/problems/merge-two-sorted-lists/
题目:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first
two ...
分类:
其他好文 时间:
2015-03-09 11:05:29
阅读次数:
134
Merge Sorted Array问题: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 tha...
分类:
其他好文 时间:
2015-03-08 21:28:44
阅读次数:
122
Remove Duplicates from Sorted Array II问题:Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array ...
分类:
其他好文 时间:
2015-03-08 21:19:36
阅读次数:
132