码迷,mamicode.com
首页 >  
搜索关键字:sorted    ( 5925个结果
Search in Rotated Sorted Array--leetcode
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array return its inde...
分类:其他好文   时间:2014-11-28 16:26:46    阅读次数:142
【leetcode】 Search a 2D Matrix (easy)
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...
分类:其他好文   时间:2014-11-28 15:48:59    阅读次数:141
[LeetCode] 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 lists.注意写出鲁棒性的代...
分类:其他好文   时间:2014-11-27 23:30:28    阅读次数:202
【leetcode】Convert Sorted Array to Binary Search Tree (easy)
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.有序数组变二叉平衡搜索树,不难,递归就行。每次先序建立根节点(取最中间的数),然后用子区间划分左右子树。一...
分类:其他好文   时间:2014-11-27 23:20:29    阅读次数:269
Merge k Sorted Lists -- leetcode
Merge k Sorted ListsMerge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.两种实现方法,第一种采用优先队列,第二种采用分治/** * Definition for singly-linked list. * struct ListNo...
分类:其他好文   时间:2014-11-27 20:36:39    阅读次数:227
LeetCode:Remove Duplicates from Sorted Array II
题目描述: Follow up for "Remove Duplicates": What if duplicates are allowed at most twice? For example, Given sorted array A = [1,1,1,2,2,3], Your function should return length = 5, and A is ...
分类:其他好文   时间:2014-11-27 16:16:38    阅读次数:122
Search for a Range
Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithm's runtime complexity must be in the order of O(log n). If the target is not found ...
分类:其他好文   时间:2014-11-27 14:34:49    阅读次数:200
Search in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target value to search. If found in the array retur...
分类:其他好文   时间:2014-11-27 14:33:08    阅读次数:210
LeetCode Merge Two Sorted Lists 归并排序
1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), ne...
分类:编程语言   时间:2014-11-26 23:59:34    阅读次数:350
[leetcode]
问题描述: Follow up for "Find Minimum in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time complexity? How and why? Suppose a sorted array is rotated at som...
分类:其他好文   时间:2014-11-26 22:40:43    阅读次数:240
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!