码迷,mamicode.com
首页 >  
搜索关键字:median of two sorted    ( 17004个结果
LeetCode:Same Tree
Same Tree      Given two binary trees, write a function to check if they are equal or not.     Two binary trees are considered equal if they are structurally identical and the n...
分类:其他好文   时间:2014-06-19 12:49:17    阅读次数:301
LeetCode——Balanced Binary Tree
Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe...
分类:其他好文   时间:2014-06-19 11:23:05    阅读次数:204
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 /** 2 * Definition for binary tree 3 * st.....
分类:其他好文   时间:2014-06-16 00:33:31    阅读次数:252
Count and Say
题目 The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11. 11 is read off as "two 1s" or 21. 21 i...
分类:其他好文   时间:2014-06-15 18:51:33    阅读次数:220
[LeetCode] Search in Rotated Sorted Array [35]
旋转数组中的查找。[1, 2, 3, 4, 5, 6]的一个旋转数组为[4, 5, 6, 1, 2, 3]。在旋转数组中寻找一个数。 最直接的方法,一次遍历,时间复杂度O(n)。但是既然是一个部分有序的数组,那么对于有序的部分我们可以想方法用二分查找。这个效率可以提高。 代码: .......
分类:其他好文   时间:2014-06-15 17:33:21    阅读次数:195
Search Insert Position
题目 Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates i...
分类:其他好文   时间:2014-06-15 17:27:16    阅读次数:251
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 i...
分类:其他好文   时间:2014-06-15 16:53:32    阅读次数:177
[LeetCode] Search for a Range [34]
题目 Given a sorted array of integers, find the starting and ending position of a given target value. 解题思路: 查找一个数出现的范围,给一个排好序的数组和一个数,找出这个数在数组中出现的范围。 这个题直接使用一次遍历就可以得到结果,这样的时间复杂度为O(n)。但是对于有序数组我们一般可以使用二分查找可以得到更好的O(logn)的时间复杂度。我们可以使用二分查找找到这个数第一次出现的位置和这个数最后一次出现的位...
分类:其他好文   时间:2014-06-15 16:19:16    阅读次数:237
Multiply Strings
题目 Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non-negative. 方法 将num1与0-9相乘的结果存...
分类:其他好文   时间:2014-06-14 06:08:30    阅读次数:229
Leetcode:Swap Nodes in Pairs 链表成对交换节点
Swap Nodes in Pairs:Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2...
分类:其他好文   时间:2014-06-13 17:04:27    阅读次数:180
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!