08 2015 档案

25.Reverse Nodes in k-Group (List)
摘要:Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of nodes is not a multiple of k then l 阅读全文

posted @ 2015-08-23 08:59 joannae 阅读(201) 评论(0) 推荐(0)

24.Swap Nodes in Pairs (List; Two-Pointers)
摘要: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.Your algor... 阅读全文

posted @ 2015-08-12 21:13 joannae 阅读(248) 评论(0) 推荐(0)

23.Merge k Sorted Lists (Array, Queue; Sort)
摘要:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 思路I: 选择排序 每次都比较各个list的头指针所指的val,取最小的那个。时间复杂度O(n*k) 阅读全文

posted @ 2015-08-11 18:45 joannae 阅读(214) 评论(0) 推荐(0)

22.Generate Parentheses (String; Back-Track)
摘要:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: " 阅读全文

posted @ 2015-08-05 18:49 joannae 阅读(186) 评论(0) 推荐(0)

导航