码迷,mamicode.com
首页 >  
搜索关键字:sorted list ii    ( 64619个结果
list,set,map,数组间的相互转换
list,set,map,数组间的相互转换...
分类:其他好文   时间:2014-05-15 07:20:06    阅读次数:239
调bug心得及一个很二的bug
有时候运行结果错误,但是vs没抛异常,这时可以用trycatch来帮我们捕捉异常。 例如:bug的情况是treeview只显示一个根节点和一个子节点,还不报错,我擦~ private void f_script_Load(object sender, EventArgs e) { List parents = new t_scriptsBLL().g...
分类:其他好文   时间:2014-05-15 07:06:00    阅读次数:202
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 树 Binary Tree Level Order Traversal II
题意:从底往上按层遍历二叉树 思路: 思路和Binary Tree Level Order Traveral 一样, 即从上往下按层遍历二叉树,将每一层的节点存放到该层对应的数组中 最后将得到的数组倒转一下就可以了 按层遍历二叉树可用bfs,也可用dfs,但都要记录节点所在的层 复杂度:时间O(n), 空间O(n)...
分类:其他好文   时间:2014-05-15 06:32:14    阅读次数:278
Leetcode 树 Populating Next Right Pointers in Each Node II
题意:给定一棵任意二叉树(不一定是perfect binary tree),将它每一个节点的next指针都指向该节点右边的节点 思路:bfs 这里不能用dfs了,只能用bfs bfs遍历将同一层的节点存放在同一个数组里, 然后在遍历每个数组,将前面的节点和后面的节点connect起来, 最后一个节点和NULL connect起来 需要定义一个新的struct结构,保存指向每个节点的指针和该节点所在的层 复杂度:时间O(n), 空间O( n)...
分类:其他好文   时间:2014-05-15 06:12:13    阅读次数:294
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第一刷_Combination Sum Combination Sum II
啊啊啊啊,好怀念这种用递归保存路径然后打印出来的题目啊,好久没遇到了。 分了两种,一种是可以重复使用数组中数字的,一种是每个数字只能用一次的。其实没有多大区别,第一种每次进入递归的时候都要从头开始尝试,第二种要找一个标记的数组,把已经用到过的排除掉,就像生成全排列时的做法一样。跟我一样用引用保存中间结果的话,要注意回退的情况。第二种回退时,要把用到的那个数也恢复为可用,就完全像全排列时做的一样。...
分类:其他好文   时间:2014-05-15 04:46:34    阅读次数:272
【LeetCode】Plus One
题目 Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list. 解答 本题考察进位问题,注...
分类:其他好文   时间:2014-05-15 04:16:56    阅读次数:245
leetcode题目:Palindrome Partitioning 和Palindrome Partitioning II
题目一: Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For example, given s = "aab", Return [ ...
分类:其他好文   时间:2014-05-14 15:10:01    阅读次数:293
LeetCode Sort List
在 O(nlogn)的时间内对一个链表进行排序。。明显是要用归并或者快排 第一次知道说原来归并也可以用链表来写,被刷了下三观。。。。。用快慢指针的方法找分界点。 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNod...
分类:其他好文   时间:2014-05-14 15:03:49    阅读次数:230
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!