02-线性结构3 Reversing Linked List (25分) Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. Fo ...
分类:
其他好文 时间:
2020-03-11 23:38:11
阅读次数:
110
206. 反转链表 难度简单反转一个单链表。示例:输入: 1->2->3->4->5->NULL输出: 5->4->3->2->1->NULL进阶:你可以迭代或递归地反转链表。你能否用两种方法解决这道题? /** * Definition for singly-linked list. * stru ...
分类:
其他好文 时间:
2020-03-10 13:41:48
阅读次数:
81
恢复内容开始 1、暴力法 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NU ...
分类:
其他好文 时间:
2020-03-09 17:40:42
阅读次数:
64
题目:1367. 二叉树中的列表 链接:https://leetcode-cn.com/problems/linked-list-in-binary-tree/ 题意:略 思路:两种思路太久没有做算法题了。对这类题目不敏感,想当然以为是dp做法,其实就是dfs或者bfs。 dfs做法:从最开始进行思 ...
分类:
其他好文 时间:
2020-03-06 12:47:11
阅读次数:
43
一、题目说明 题目114. Flatten Binary Tree to Linked List,将一个二叉树“原地”压缩为“链表”形态的二叉树。难度为Medium! 二、我的解答 这个题目如果允许使用栈的话Easy,先序遍历二叉树,右子树入栈,左子树入栈。当栈不空的时候,将栈顶元素放到右子树即可。 ...
分类:
其他好文 时间:
2020-03-06 10:51:48
阅读次数:
74
Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, ...
分类:
其他好文 时间:
2020-03-05 13:49:20
阅读次数:
86
一、暴力解法 二、哈希表思路 将A链表放入哈希表中,对B链表进行遍历,查询是否有元素存在哈希表中。 哈希表建立方法: set<ListNode*>hash; 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * ...
分类:
其他好文 时间:
2020-03-04 12:52:12
阅读次数:
70
线性表(Linear List) 顺序存储结构 顺序表(Sequence List) 顺序栈(Sequence Stack) 循环队列(Circular Queue) 链式存储结构 单链表(Singly Linked List) 双链表(Doubly Linked List) 循环链表(Circul ...
分类:
编程语言 时间:
2020-03-04 00:14:43
阅读次数:
76
LeetCode 142 链表 Linked List Cycle IILeetCodeGiven a linked list, return the node where the cycle begins. If there is no cycle, return null.To represen... ...
分类:
其他好文 时间:
2020-03-03 10:50:36
阅读次数:
56
【不定时更新,赶论文,赶项目,1月~2月做题记录还在整理,自我训练】 反转链表 链接:https://leetcode cn.com/problems/reverse linked list/ 类名: 考察点:链表、迭代、递归 解题过程: 力扣3月每日1题,题解链接: https://leetcod ...
分类:
其他好文 时间:
2020-03-03 00:58:58
阅读次数:
87