摘要:
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. You may not modify the values in the list, only nodes itself can be changed.思考:考虑几种情况:空链表,单节 阅读全文
posted @ 2013-11-12 21:08
七年之后
阅读(161)
评论(0)
推荐(0)
摘要:
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.思考:合并双链表的基础上增加循环。/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode *... 阅读全文
posted @ 2013-11-12 12:47
七年之后
阅读(149)
评论(0)
推荐(0)

浙公网安备 33010602011771号