LeetCode #24 Swap Nodes in Pairs (M)

摘要: [Problem]Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Y... 阅读全文
posted @ 2015-10-24 03:23 张惬意 阅读(112) 评论(0) 推荐(0) 编辑

LeetCode #23 Merge k Sorted Lists (H)

摘要: [Problem]Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.[Analysis]这题一上来,就会想到之前做过的Merge Two Sorted Lis... 阅读全文
posted @ 2015-10-23 05:14 张惬意 阅读(263) 评论(0) 推荐(0) 编辑

LeetCode #22 Generate Parentheses (M)

摘要: [Problem]Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set i... 阅读全文
posted @ 2015-10-10 00:31 张惬意 阅读(155) 评论(0) 推荐(0) 编辑

LeetCode #21 Merge Two Sorted Lists (E)

摘要: [Problem]Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.... 阅读全文
posted @ 2015-10-09 23:56 张惬意 阅读(85) 评论(0) 推荐(0) 编辑

LeetCode #20 Valid Parentheses (E)

摘要: [Problem]Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the... 阅读全文
posted @ 2015-10-09 23:52 张惬意 阅读(135) 评论(0) 推荐(0) 编辑

LeetCode #19 Remove Nth Node From End of List (E)

摘要: [Problem]Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. ... 阅读全文
posted @ 2015-10-09 23:49 张惬意 阅读(85) 评论(0) 推荐(0) 编辑

LeetCode #18 4Sum (M)

摘要: [Problem]Given an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives th... 阅读全文
posted @ 2015-10-09 23:30 张惬意 阅读(115) 评论(0) 推荐(0) 编辑

LeetCode #17 Letter Combinations of a Phone Number (M)

摘要: [Problem]Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the... 阅读全文
posted @ 2015-10-09 23:16 张惬意 阅读(130) 评论(0) 推荐(0) 编辑

LeetCode #16 3Sum Closest (M)

摘要: [Problem]Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three intege... 阅读全文
posted @ 2015-10-09 22:58 张惬意 阅读(147) 评论(0) 推荐(0) 编辑

LeetCode #15 3Sum (M)

摘要: [Problem]Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.No... 阅读全文
posted @ 2015-10-09 22:49 张惬意 阅读(160) 评论(0) 推荐(0) 编辑