码迷,mamicode.com
首页 >  
搜索关键字:merge k sorted lists    ( 11722个结果
Add Two Numbers
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 ...
分类:其他好文   时间:2014-05-16 23:18:16    阅读次数:360
【LeetCode】Merge Intervals
Given a collection of intervals, merge all overlapping intervals.For example,Given[1,3],[2,6],[8,10],[15,18],return[1,6],[8,10],[15,18].public class S...
分类:其他好文   时间:2014-05-16 08:44:29    阅读次数:276
insert ,update 以及merge 的使用
insert ,update 以及merge 的使用例子
分类:其他好文   时间:2014-05-16 05:03:57    阅读次数:307
Leetcode 线性表 Remove Duplicates from Sorted Array
题意:从一个已排序的数组中移除掉重复的元素 思路:用下标i扫描旧数组,用下标j来保存新数组的尾部 如果旧数组的当前元素与新数组的最后一个元素相同,则继续扫描旧数组 如果不同,新数组的下标前移一们,将旧数组的当前元素赋给新数组,继续扫描旧数组 相关题目: Remove Element Remove Duplicates from Sorted List Remove Duplicates from Sorted List II...
分类:其他好文   时间:2014-05-15 06:57:53    阅读次数:249
Leetcode 线性表 Remove Duplicates from Sorted List
题意:去掉已排序的链表里重复的元素 思路: 1.遍历链表,用一个变量保存当前链表节点的值 2.如果当前链表节点值与前面的一样,则删除当前链表节点 3.否则用当前节点值更新该变量 复杂度:时间O(n), 空间O(1)...
分类:其他好文   时间:2014-05-15 06:46:24    阅读次数:218
LeetCode-004 Add Two Numbers
【题目】 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 linked list. Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) Out...
分类:其他好文   时间:2014-05-15 05:13:49    阅读次数:306
leetCode-002 Median of Two Sorted Arrays
leetCode-002 Median of Two Sorted Arrays 【题目】 There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). 【题意】 有两个有序的数组,找出这两数组整合后的中位数,要求时间复杂度O(nlogn)...
分类:其他好文   时间:2014-05-15 04:42:05    阅读次数:274
【LeetCode】Search a 2D Matrix
题目 Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right.The first integer...
分类:其他好文   时间:2014-05-15 03:41:11    阅读次数:257
Leetcode 线性表 Remove Duplicates from Sorted List II
题意:将已排序的链表中所有重复的元素移除 思路: 三个个指针,pre, cur, next 一个布尔变量is_appear,表示cur指针指向的值之前是否已经出现过 检查cur, next指向的节点的值是否相同, 相同的话,删除cur 不同的话,如果is_appear为true,删除cur,否则不删除 删除的话,只移动cur, next指针 不删除的话,要移动pre, cur, next三个指针 复杂度:时间O(n),空间O(1)...
分类:其他好文   时间:2014-05-15 02:54:32    阅读次数:262
Leetcode 线性表 Remove Duplicates from Sorted Array II
题意:从一个已排序的数组中移除掉重复的元素,每个元素最多可重复两次 思路: 思路和Remove Duplicates from Sorted Array一样,不过要设置一个计数变量,表示当前值出现的次数 出现次数少于2可以加入到新数组,多于2则不可以。每次遇到一个新变量要把计数变量重新设置为1,加入新数组要加1 复杂度:时间O(n), 空间O(1)...
分类:其他好文   时间:2014-05-14 21:03:00    阅读次数:262
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!