摘要:
Linked List CycleGiven a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?SOLUTION 1:经典快慢指针问题。如果存在环... 阅读全文
摘要:
Rotate ListGiven a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5... 阅读全文
摘要:
Surrounded RegionsGiven a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's i... 阅读全文
摘要:
Sort ListSort a linked list in O(n log n) time using constant space complexity.使用Merge Sort, 空间复杂度是 O(logN) 因为使用了栈空间。SOLUTION 1:使用Merge Sort来解决问题。为什么不... 阅读全文
摘要:
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... 阅读全文