码迷,mamicode.com
首页 >  
搜索关键字:sorted    ( 5925个结果
LeetCode[Linked List]: Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 一开始我没有采用分治法,解题思路是:首先比较每条链表的第一个元素,找出最小的那个,插入新链表并从原链表删除,如此反复直至所有的链表都为空链表。基于这个愚蠢的解题思路,我的C++代码实现如下: ...
分类:其他好文   时间:2015-02-03 17:19:27    阅读次数:158
leetcode_82_Remove Duplicates from Sorted List II
思路: 大致思路就是,遍历链表找出重复元素的子列并删除重复元素子列,当然,第一个元素开始有重复元素的话比较特种,需要特殊考虑。删除子列的过程稍微有点绕,题目倒是不难理解。...
分类:其他好文   时间:2015-02-03 13:27:28    阅读次数:136
leetcode_21_Merge Two Sorted Lists
思路: 好像是数据结构上面的原题,就不多说了,通过比较把两个链表一起就可以了。需要注意的就是两个链表的head谁当新表的head问题,当然谁小谁当head 了,先比较一下即可。...
分类:其他好文   时间:2015-02-03 13:25:52    阅读次数:174
leetcode_83_Remove Duplicates from Sorted List
思路: simple,从头到尾遍历结点,如果下一个结点不为空且当前结点和下一个节点相同,删除下一个结点,否则,遍历下一个结点。...
分类:其他好文   时间:2015-02-03 11:06:43    阅读次数:137
[Leetcode][Python]33: Search in Rotated Sorted Array
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com'33: Search in Rotated Sorted Arrayhttps://oj.leetcode.com/problems/search-in-rotated-sorte...
分类:编程语言   时间:2015-02-03 01:52:49    阅读次数:218
108.Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it toa height balanced BST. HideTags  Tree  Depth-first Search #pragma once #include #include using namespace std;...
分类:其他好文   时间:2015-02-02 23:14:33    阅读次数:181
Find Minimum in Rotated Sorted Array
本文是在学习中的总结,欢迎转载但请注明出处:http://blog.csdn.net/pistolove/article/details/43416613 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). Find the minimum element. You...
分类:其他好文   时间:2015-02-02 23:13:46    阅读次数:205
LeetCode: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 elements from B....
分类:其他好文   时间:2015-02-02 23:12:19    阅读次数:171
Leetcode 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-02-02 22:58:13    阅读次数:280
Leetcode#88 Merge Sorted Array
原题地址如果不使用额外的空间,可以先将A数组整体向后挪n个单位,然后开始常规的merge操作代码: 1 void merge(int A[], int m, int B[], int n) { 2 int i = m - 1; 3 int j = 0; 4 ...
分类:其他好文   时间:2015-02-02 19:42:49    阅读次数:144
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!