leetcode
dongnuanxialiang
这个作者很懒,什么都没留下…
展开
-
Generate Parentheses
22. Generate Parentheses mediumGiven n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ "((()))", "(()(原创 2017-03-14 16:49:30 · 226 阅读 · 0 评论 -
Merge k sorted lists
23. Merge k Sorted Lists Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 本题是合并两个已经排好序的lists的扩展版,所以基于之前写过的对两个排序链表的merge过程。考虑采用归并递归的方式,每一次我们对其中的两原创 2017-03-23 21:20:29 · 203 阅读 · 0 评论 -
Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant space. Y原创 2017-04-01 11:21:03 · 180 阅读 · 0 评论