LeetCode
MrRoyLee
这个作者很懒,什么都没留下…
展开
-
[LeetCode]Longest Valid Parentheses
解题思路:原创 2014-06-23 14:51:57 · 513 阅读 · 0 评论 -
Trapping Rain Water
解题思路我的解题思路好像是全网目前知道的唯一一个哦~~思考这题时,想到了那道 Candy 题. 那道扫描两遍.这题可不可以也扫描两遍呢?答案是可以的.从左往右以当前bar i 为左bar,直到找比它大的bar j .如果找到,就算出两者的trap water.然后令i:=j,继续搜完.从右往左同理的方式搜寻(其实就是把第一遍的每个bar当做右bar).不过这里原创 2014-06-22 22:54:32 · 528 阅读 · 0 评论 -
[LeetCode]Longest Palindromic Substring
题目描述:原创 2014-06-30 18:45:03 · 557 阅读 · 0 评论 -
[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 · 439 阅读 · 0 评论 -
[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 · 463 阅读 · 0 评论 -
[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 · 436 阅读 · 0 评论 -
[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 · 515 阅读 · 0 评论 -
[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 · 870 阅读 · 0 评论 -
[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 · 518 阅读 · 0 评论 -
[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 · 548 阅读 · 0 评论 -
[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 · 735 阅读 · 0 评论