leetcode
ruan875417
这个作者很懒,什么都没留下…
展开
-
【leetcode】【单链表】【160】Intersection of Two Linked Lists
#includeusing namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: ListNode *getIntersectionNode(ListNode *headA, ListNo原创 2015-05-27 20:48:34 · 404 阅读 · 0 评论 -
【leetcode】【单链表】【61】Merge k Sorted Lists
#includeusing namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: ListNode* rotateRight(ListNode* head, int k) { if (原创 2015-05-21 16:43:27 · 404 阅读 · 0 评论 -
【leetcode】【单链表】【21】Merge Two Sorted Lists
#includeusing namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) {原创 2015-05-18 17:00:27 · 476 阅读 · 0 评论 -
【leetcode】【单链表】【25】Reverse Nodes in k-Group
#include#include#includeusing namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: pair reverseList(ListNode* head) {原创 2015-06-03 19:24:52 · 286 阅读 · 0 评论 -
【leetcode】【单链表,vector,queue】【23】Merge k Sorted Lists
#include#include#includeusing namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: ListNode* mergeTwoLists(ListNode* l原创 2015-05-19 15:32:11 · 384 阅读 · 0 评论 -
【leetcode】【单链表】【86】Partition List
#includeusing namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: ListNode* partition(ListNode* head, int x) { if (he原创 2015-05-24 16:02:22 · 410 阅读 · 0 评论 -
【leetcode】【单链表】【143】Reorder List
#includeusing namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: //翻转链表 ListNode* reverseList(ListNode* head) { Lis原创 2015-05-24 19:54:13 · 386 阅读 · 0 评论 -
【leetcode】【单链表】【109】Convert Sorted List to Binary Search Tree
#includeusing namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} };struct TreeNode { int val; TreeNode *left; TreeNode *right;原创 2015-06-09 19:25:32 · 459 阅读 · 0 评论 -
【leetcode】【单链表】【148】Sort List
#includeusing namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: ListNode* merge(ListNode* l1, ListNode* l2){ ListNo原创 2015-05-25 18:29:52 · 439 阅读 · 0 评论 -
【leetcode】【单链表】【24】Swap Nodes in Pairs
#includeusing namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: ListNode* swapPairs(ListNode* head) { if (head==NUL原创 2015-05-14 15:18:48 · 357 阅读 · 0 评论 -
【leetcode】【单链表,queue】【2】Add Two Numbers
#include#includeusing namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: ListNode* addTwoNumbers(ListNode* l1, ListNo原创 2015-05-15 18:48:40 · 429 阅读 · 0 评论 -
【leetcode】【单链表】【19】Remove Nth Node From End of List
#includeusing namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: ListNode* removeNthFromEnd(ListNode* head, int n) {原创 2015-05-13 16:42:34 · 310 阅读 · 0 评论 -
【leetcode】【单链表】【206】Reverse Linked List
#includeusing namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: ListNode* reverseList(ListNode* head) { ListNo原创 2015-05-10 09:34:40 · 382 阅读 · 0 评论 -
【leetcode】【单链表】【92】Reverse Linked List II
#includeusing namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: ListNode* reverseBetween(ListNode* head, int m, int n原创 2015-05-10 10:22:19 · 335 阅读 · 0 评论 -
【leetcode】【单链表】【141】Linked List Cycle
#includeusing namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: bool hasCycle(ListNode *head) { if (head == NULL ||原创 2015-05-11 15:14:01 · 316 阅读 · 0 评论 -
【leetcode】【单链表】【142】Linked List Cycle II
#includeusing namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: ListNode *detectCycle(ListNode *head) { ListNode* s原创 2015-05-11 16:22:30 · 413 阅读 · 0 评论 -
【leetcode】【单链表】【83】Remove Duplicates from Sorted List
#include#includeusing namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: ListNode* deleteDuplicates(ListNode* head) {原创 2015-05-12 15:45:17 · 352 阅读 · 0 评论 -
【leetcode】【单链表】【82】Remove Duplicates from Sorted List II
#include#includeusing namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: ListNode* deleteDuplicates(ListNode* head) {原创 2015-05-12 16:29:48 · 394 阅读 · 0 评论 -
【leetcode】【单链表】【203】Remove Linked List Elements
#includeusing namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: ListNode* removeElements(ListNode* head, int val) {原创 2015-05-13 15:59:45 · 425 阅读 · 0 评论 -
【leetcode】【单链表】【147】Insertion Sort List
#includeusing namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: ListNode* insertionSortList(ListNode* head) { if (h原创 2015-05-25 16:17:55 · 416 阅读 · 0 评论