![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode链表栈队列问题
文章平均质量分 64
大疯疯
这个作者很懒,什么都没留下…
展开
-
LeetCode 203. Remove Linked List Elements *****虚拟头结点
题目题意注意思路代码结果题目 Remove all elements from a linked list of integers that have value val. Example Given: 1 –> 2 –> 6 –> 3 –> 4 –> 5 –> 6, val = 6 Return: 1 –> 2 –> 3 –> 4 –> 5 题意 给定一个原创 2017-05-22 15:00:19 · 495 阅读 · 0 评论 -
LeetCode 107. Binary Tree Level Order Traversal II 树的BFS、DFS
Binary Tree Level Order Traversal II题意思路代码BFSDFS107. Binary Tree Level Order Traversal II Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to原创 2017-05-25 22:28:00 · 716 阅读 · 0 评论 -
LeetCode 206. Reverse Linked List *****三指针 (pre,cur,next)
题目题意注意思路题目 Reverse a singly linked list.题意 反转一个单链表 e.g: 1->2->3->4->5->NULL NULL<-1<-2<-3<-4<-5注意 链表的题目一般不允许修改链表内的内容,只能修改指向思路 需要三个指针,分别保存之前,当前,之后的信息。 1.更改cur的next指向 2.之后pre原创 2017-05-20 21:40:23 · 1152 阅读 · 0 评论 -
LeetCode 2. Add Two Numbers ***** 进位的巧妙解决
题目 You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and retu原创 2017-05-22 10:47:41 · 437 阅读 · 0 评论 -
LeetCode 83. 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.原创 2017-05-20 22:32:52 · 226 阅读 · 0 评论 -
LeetCode 92. Reverse Linked List II ***** 虚拟头结点
题目题意注意思路代码题目 Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL. Not原创 2017-05-20 22:01:01 · 280 阅读 · 0 评论 -
LeetCode 226. Invert Binary Tree 递归、指针交换 思考链表的交换
226. Invert Binary Tree Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1Trivia: This problem was i原创 2017-05-31 14:53:15 · 271 阅读 · 0 评论 -
LeetCode 347. Top K Frequent Elements 优先队列的使用及注意事项
Top K Frequent Elements题意注意思路代码结果优先队列的使用347. Top K Frequent Elements Given a non-empty array of integers, return the k most frequent elements. For example, Given [1,1,1,2,2,3] and k = 2原创 2017-05-26 17:38:10 · 672 阅读 · 0 评论 -
LeetCode 20. Valid Parentheses 辅助数据结构栈
Valid Parentheses题意注意思路代码结果20. Valid Parentheses Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid. The brackets must clo原创 2017-05-24 11:34:25 · 372 阅读 · 0 评论 -
LeetCode 150. Evaluate Reverse Polish Notation 辅助数据结构栈
题目题意注意思路代码结果题目 Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression. Some exa原创 2017-05-24 11:17:12 · 311 阅读 · 0 评论 -
LeetCode 19. Remove Nth Node From End of List 对撞指针
Remove Nth Node From End of List题目题意注意思路代码结果Delete Node in a Linked List题目题意注意思路代码结果19.Remove Nth Node From End of List题目 Given a linked list, remove the nth node from the end of list an原创 2017-05-23 17:38:21 · 348 阅读 · 0 评论 -
LeetCode 24. 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原创 2017-05-23 16:34:15 · 221 阅读 · 0 评论 -
LeetCode 82. Remove Duplicates from Sorted List II pre指针,首元素的处理
题目题意注意思路代码结果题目 Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example, Given 1->2->3->3->4->4->5, ret原创 2017-05-23 15:31:04 · 329 阅读 · 0 评论 -
148. Sort List (归并) 和147. Insertion Sort List
148. Sort List Sort a linked list in O(n log n) time using constant space complexity.题意 对一个链表进行排序,要求时间复杂度O(nlogn),一般就是快排、归并、堆排序。这里选择归并排序思路 分为两个步骤,一个步骤是拆分,直至都是单个结点,拆分使用了三个指针pre、slow、fast。slow走一步原创 2017-09-05 17:29:36 · 219 阅读 · 0 评论