码迷,mamicode.com
首页 >  
搜索关键字:sorted    ( 5925个结果
二分搜索 float
Given a sorted array of floats, find the index of the number closest to x: Example: {1.2, 2.5, 9.3} x = 5, return 1#include#include#include using name...
分类:其他好文   时间:2015-01-19 15:39:44    阅读次数:160
Leetcode#154 Find Minimum in Rotated Sorted Array II
原题地址说个题外话,我一直想不明白题目里rotate这个词,感觉用shift更合适啊仔细分析题目,有如下两个性质:1. 对于一个没有折叠过的数组,最小值一定是第一个元素。2. 对于一个折叠过的数组,最小值一定出现在折叠的地方。因此,要找最小值,就把以上两种情况下的最小值都看看,选一个最小的就行了。这...
分类:其他好文   时间:2015-01-19 12:16:31    阅读次数:92
[LeetCode] Find the k-th Smallest Element in the Union of Two Sorted Arrays
Question:GiventwosortedarraysA,Bofsizemandnrespectively.Findthek-thsmallestelementintheunionofAandB.Youcanassumethattherearenoduplicateelements.http://leetcode.com/2011/01/find-k-th-smallest-element-in-union-of.htmlAspecialcase:Medianoftwosortedarrayshttps:..
分类:其他好文   时间:2015-01-19 11:05:14    阅读次数:214
《数据结构复习笔记》--二叉搜索树
二叉查找树(Binary Search Tree),也称二叉搜索树、有序二叉树(ordered binary tree),排序二叉树(sorted binary tree),是指一棵空树或者具有下列性质的二叉树:...
分类:其他好文   时间:2015-01-18 22:45:47    阅读次数:336
Convert Sorted List to Balanced Binary Search Tree (BST)
(http://leetcode.com/2010/11/convert-sorted-list-to-balanced-binary.html)Given a singly linked list where elements are sorted in ascending order, conv...
分类:其他好文   时间:2015-01-18 22:18:49    阅读次数:202
【leetcode】Convert Sorted List to Binary Search Tree (middle)
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.思路:题目看上去好像很难,但实际上很简单,递归做就行,每次找到左右子树对应的子链表...
分类:其他好文   时间:2015-01-18 21:03:17    阅读次数:241
【leetcode】Remove Duplicates from Sorted List (easy)
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-01-18 21:00:44    阅读次数:200
Leetcode Merge k Sorted Lists
Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.对于这道题,之前并不知道java中有一个封装好的数据结构--优先队列。优先队列其实相当于一个最大或最小堆,能...
分类:其他好文   时间:2015-01-18 18:24:56    阅读次数:210
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 ord...
分类:其他好文   时间:2015-01-18 17:04:57    阅读次数:198
Leetcode#4 Median of two sorted arrays
原题地址将“寻找中位数”转化成更一般化的“寻找第k大的数”这个问题。因为数组已经排序,所以可以使用二分缩小范围,使得时间复杂度满足要求。假设A、B数组里都至少有k/2个元素,那么可以将k平均划分成k/2和k/2两半,在A里找第k/2大的元素,在B里找k/2大的元素(对k划分,解题的关键)。因为数组已...
分类:其他好文   时间:2015-01-18 14:25:07    阅读次数:125
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!