![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode之单链表
CuteRainbow
我是一个热爱生活的人
展开
-
【LeetCode】之Remove Nth Node From End of List
Remove Nth Node From End of ListGiven a linked list, remove the nth node from the end of list and return its head.For example,Given linked list: 1->2->3->4->5, and n = 2.After removing the second node原创 2015-08-26 21:38:22 · 238 阅读 · 0 评论 -
【LeetCode】之Linked List Cycle
Given a linked list, determine if it has a cycle in it.此题目的在于判断一个链表是否是一个循环链表。思路: 1.先定义两个节点指针first和second; 2.first每次走一步,second每次走两步; 3.若second && second->next为NULL,则返回false,此判断是因为如果second为NULL,则 sec原创 2015-08-31 20:32:35 · 221 阅读 · 0 评论 -
【LeetCode】之Swap Nodes in Pairs
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 2->1->4->3. Your algorithm should use only原创 2015-08-26 22:22:11 · 203 阅读 · 0 评论 -
【LeetCode】之Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3. 此题目的在于将一个已排好序的链表中重复的节点删除,只保留一个。原创 2015-09-02 11:10:36 · 342 阅读 · 0 评论 -
【LeetCode】之Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linke原创 2015-09-03 09:44:35 · 277 阅读 · 0 评论