码迷,mamicode.com
首页 >  
搜索关键字:sorted lists    ( 7805个结果
[leetcode]Search Insert Position @ Python
原题地址:https://oj.leetcode.com/problems/search-insert-position/题意:Given a sorted array and a target value, return the index if the target is found. If n...
分类:编程语言   时间:2014-06-11 11:28:40    阅读次数:349
leetcode--Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.public class Solution { /** Convert th...
分类:其他好文   时间:2014-06-10 00:22:44    阅读次数:259
LEETCODE--Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3-...
分类:其他好文   时间:2014-06-08 21:56:41    阅读次数:297
leetcode——Add Two Numbers 两个链表表示的正整数对其求和(AC)
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link...
分类:其他好文   时间:2014-06-08 15:30:28    阅读次数:227
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 that is greater or equal to m + n) to hold additional el...
分类:其他好文   时间:2014-06-08 05:05:47    阅读次数:268
[LeetCode] Remove Duplicates from Sorted Array [19]
题目...For example,Given input array A = [1,1,2],Your function should return length = 2, and A is now [1,2]. 解题思路, 移除数组中的重复元素,并返回新数组的长度。 这个题目应该算是简单的题目。使用两个变量就可以。具体的看代码 代码实现......
分类:其他好文   时间:2014-06-08 03:54:22    阅读次数:279
[LeetCode] Median of Two Sorted Arrays [16]
求两个排序数组的中位数。这个题可以有以下几个思路: 首先可以想到的是将两个数组merge起来,然后返回其中位数。 第二个是,类似merge的思想加上计数,找到(m+n)/2个数或者其前后的数,这个就可以算出中位数。这个方法对于各种情况需要一一考虑到。 第三个,假设A[k/2-1]<B[k/2-1],那么A[k/2-1]之前的数一定在整个有序数列中(m+n)/2之前。 这里我给出后面两种思路的代码。 代码一( 思路三)...
分类:其他好文   时间:2014-06-08 03:44:47    阅读次数:231
leetcode--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 7might become4 5 6 7 0 1 2).You are given a target value t...
分类:其他好文   时间:2014-06-08 02:05:43    阅读次数:311
leetcode--Search in Rotated Sorted Array II
Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to...
分类:其他好文   时间:2014-06-08 01:19:29    阅读次数:320
Python的二维数组
Python一维数组初始化:>>> list=[]>>> type(list)>>> list[]Python二维数组初始化:>>> lists = [[]] * 3>>> lists[[], [], []]>>> lists[0].append(3)>>> lists[[3], [3], [3]]...
分类:编程语言   时间:2014-06-07 23:49:56    阅读次数:563
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!