码迷,mamicode.com
首页 >  
搜索关键字:sorted lists    ( 7805个结果
Merge k Sorted Lists
Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.思路:合并k个有序链表为一个有序链表。我们可以用先合并两个链表的方法,然后逐个遍历链表数组,与上一个合并结束...
分类:其他好文   时间:2014-05-12 15:07:06    阅读次数:305
Leetcode | 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 ...
分类:其他好文   时间:2014-05-09 23:26:18    阅读次数:353
Leetcode: Merge Two Sorted Lists
一点小错,两次过,基本思想是先比较头元素,哪个小就在哪个list的基础上插入,需要考虑两种不同的结束方式 1 /** 2 * Definition for singly-linked list. 3 * public class ListNode { 4 * int val; 5 *...
分类:其他好文   时间:2014-05-09 09:21:59    阅读次数:273
Leetcode:Search a 2D Matrix
戳我去解题Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted f...
分类:其他好文   时间:2014-05-09 08:27:24    阅读次数:241
ubuntu下安装lex,yacc
最近在看这本书。不过发现需要安装编译工具 lex, yacc。书上说Linux自带lex, yacc。不过我发现我的没有。并且,ubuntu不使用lex, yacc。输入sudo apt-get install yacc lex 会报错, 报错内容如下:Reading package lists... Done Building dependency tree Reading sta...
分类:其他好文   时间:2014-05-09 06:18:48    阅读次数:989
LeetCode OJ - Merge Sorted Array
原地归并。下面是AC代码: 1 public void merge(int A[], int m, int B[], int n) { 2 3 int len = A.length; 4 //first copy m elements of A...
分类:其他好文   时间:2014-05-09 05:59:54    阅读次数:297
LeetCode -- Remove Duplicates from Sorted List
题目链接简单题,就是从单链表中删除重复元素。附上代码: 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * L...
分类:其他好文   时间:2014-05-08 18:02:52    阅读次数:338
leetcode第一刷_Convert Sorted List to Binary Search Tree
好,二叉搜索树粉末登场,有关他的问题有这么几个,给你一个n,怎样求所有的n个节点的二叉搜索树个数?能不能把所有的这些二叉搜索树打印出来? 这道题倒不用考虑这么多,直接转就行了,我用的思想是分治,每次找到一半的位置,分离出中间节点,作为新子树的根节点,然后递归构造前半部分和后半部分。 class Solution { public: TreeNode *sortedListToBST(L...
分类:其他好文   时间:2014-05-08 11:07:14    阅读次数:266
Common Issues Which Cause Roles to Recycle
This section lists some of the common causes of deployment problems, and offers troubleshooting tips to help you resolve the problems. An indication t...
分类:其他好文   时间:2014-05-08 09:31:31    阅读次数:447
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 or...
分类:其他好文   时间:2014-05-08 07:29:02    阅读次数:285
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!