- 博客(12)
- 收藏
- 关注
原创 [LeetCode]Rotate List
描述Given a list, rotate the list to the right bykplaces, wherekis non-negative.2.2 单链表 45For example: Given1->2->3->4->5->nullptrandk = 2, return 4->5->1->2->3->nullptr.分析先遍历一遍,得出链表长度len,注意k可能大于len,因此令
2014-06-27 16:52:15 454
原创 [LeetCode]Partition List
描述Given a linked list and a valuex, partition it such that all nodes less than xcome before nodes greaterthan or equal tox.You should preserve the original relative order of the nodes in each
2014-06-27 16:36:45 479
原创 [LeetCode]Reverse Linked List II
描述Reverse a linked list from positionmto n. Do it in-place and in one-pass.For example: Given1->2->3->4->5->nullptr, m= 2 andn= 4,return1->4->3->2->5->nullptr.Note: Given m, n satisfy the foll
2014-06-27 15:59:45 453
原创 [LeetCode]Single Number II
题目描述:Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it with
2014-06-27 15:29:08 531
原创 [LeetCode]Gray Code
题目描述:The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print t
2014-06-27 11:27:45 529
原创 [LeetCode]Permutation Sequence
题目描述:The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""21
2014-06-27 10:38:29 883
原创 [LeetCode] Next Permutation
题目描述Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowes
2014-06-26 23:35:23 749
原创 [LeetCode] Longest Consecutive Sequence
题目描述:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [
2014-06-26 23:05:42 564
原创 Trapping Rain Water
解题思路我的解题思路好像是全网目前知道的唯一一个哦~~思考这题时,想到了那道 Candy 题. 那道扫描两遍.这题可不可以也扫描两遍呢?答案是可以的.从左往右以当前bar i 为左bar,直到找比它大的bar j .如果找到,就算出两者的trap water.然后令i:=j,继续搜完.从右往左同理的方式搜寻(其实就是把第一遍的每个bar当做右bar).不过这里
2014-06-22 22:54:32 542
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人