码迷,mamicode.com
首页 >  
搜索关键字:sorted    ( 5925个结果
LeetCode -- Search in Rotated Sorted Array(Binary Search)
题目地址:https://leetcode.com/problems/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 give...
分类:其他好文   时间:2015-03-16 17:48:11    阅读次数:97
Quick Sort
def quick_sort(array): """ Returns a sorted 'array' by quick sort algorithm via list comprehension, here 'array' is actually a list. """ ...
分类:其他好文   时间:2015-03-16 14:12:07    阅读次数:84
Remove Duplicates from Sorted List
删除一个有序单链表的重复节点 For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3. 思路:两个指针,一前一后,前面指针的值与后面指针的值相等就往前,直到不同,后指针的下一个节点指向前指针,然后继续。注意...
分类:其他好文   时间:2015-03-16 12:34:58    阅读次数:132
Lintcode: Median
Given a unsorted array with integers, find the median of it. A median is the middle number of the array after it is sorted. If there are even numbers ...
分类:其他好文   时间:2015-03-16 06:14:57    阅读次数:119
Lintcode: Merge Sorted Array
Merge two given sorted integer array A and B into a new sorted integer array.ExampleA=[1,2,3,4]B=[2,4,5,6]return [1,2,2,3,4,4,5,6]ChallengeHow can you...
分类:其他好文   时间:2015-03-16 06:11:42    阅读次数:212
【LeetCode】median of two sorted arrays
题目:median of two sorted arrays 知识点:二分查找,中位数定义 public class Solution { /* * 关于:leetcode 第二题 给定两个排好序的数组,找到它们的中位数,要求:时间复杂度o(log(m+n)); * 变形:找第k个数 * 方法:1.遍历,时间复杂度为o(m+n),从头开始分别遍历两数组的数,按照大小计数...
分类:其他好文   时间:2015-03-16 01:01:30    阅读次数:172
[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.一直没想出原址排序...
分类:其他好文   时间:2015-03-16 00:50:25    阅读次数:215
[Leetcode]Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.分治是比较好而且容易想到的思路。 1 class Solution { 2 public: 3 T...
分类:其他好文   时间:2015-03-15 23:32:20    阅读次数:212
Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, retu...
分类:其他好文   时间:2015-03-15 21:15:12    阅读次数:123
Remove Duplicates from Sorted List II
Remove Duplicates from Sorted List II问题:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the...
分类:其他好文   时间:2015-03-15 12:18:01    阅读次数:101
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!