链表
dherorunner
光电信息科学专业,有志考研计算机。
展开
-
leetcode 判断简单链表是否存在循环
/*struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};*/class Solution {public: bool hasCycle(ListNode *head) { ListNode*原创 2017-03-28 20:45:57 · 361 阅读 · 0 评论 -
Delete Node in a Linked List 删除指针指向的元素
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: void deleteN原创 2017-03-28 21:08:32 · 360 阅读 · 0 评论 -
Merge Two Sorted List
ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) { if(NULL == l1) return l2; if(NULL == l2) return l1; ListNode* head=NULL; // head of the list to return // find f原创 2017-03-30 22:36:05 · 222 阅读 · 1 评论