guttttzhi
guttttzhi
全部文章
题解
Java专项(1)
归档
标签
去牛客网
登录
/
注册
guttttzhi的博客
全部文章
/ 题解
(共30篇)
题解 | #二维数组中的查找#
根据题目所给的性质,我们可以将起始位置定位在右上角 class Solution { public: bool Find(int target, vector<vector<int> > array) { int row = array.size...
C++
2022-05-26
0
290
题解 | #判断一个链表是否为回文结构#
利用栈的性质。将链表中一般的数据存放在栈中。 /** * struct ListNode { * int val; * struct ListNode *next; * }; */ class Solution { public: /** * * @...
C++
2022-05-26
0
381
题解 | #链表相加(二)#
栈的应用 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL...
C++
2022-05-26
0
347
题解 | #删除链表的倒数第n个节点#
主要思路:定义两个指针,先移动其中的一个指针,使得他们之间的差为n。之后就同时移动指针。 /** * struct ListNode { * int val; * struct ListNode *next; * }; */ class Solution { public: /...
C++
2022-05-26
0
323
题解 | #两个链表的第一个公共结点#
主要思路:寻找两个链表之间长度的差值。让长的链表移动一定的差值距离,使得此时两个指针遍历的长度一致,如果在遍历的过程中出现两个指针相等,说明存在相同节点。 /* struct ListNode { int val; struct ListNode *next; ListNo...
C++
2022-05-26
0
278
题解 | #链表中倒数最后k个结点#
定义两个指针,开始时都位于头节点,先让其中的一个指针先走,使得两个指针之间的节点各位为k,这时就同时移动两个指针。 /** * struct ListNode { * int val; * struct ListNode *next; * ListNode(int x) : val(...
C++
2022-05-26
0
293
题解 | #链表中环的入口结点#
快慢指针应用 /* struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { } }; */ class Solution { ...
C++
2022-05-26
0
284
题解 | #判断链表中是否有环#
快慢指针 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL...
C++
2022-05-26
0
235
题解 | #链表中的节点每k个一组翻转#
/** * struct ListNode { * int val; * struct ListNode *next; * }; */ class Solution { public: /** * * @param head ListNode类 ...
C++
2022-05-26
0
216
题解 | #链表内指定区间反转#
主要思路 定义prefront指针、front指针 初始时各个指针的状态。dummyHead是新创建的虚拟头节点,目的就是为了在遍历的过程中找到当前节点的前驱节点。 在cur指针不断的移动的过程中,如果遇到了要翻转的第一个节点。记录下当前节点和前驱节点 if(index==m)...
C++
2022-05-26
0
477
首页
上一页
1
2
3
下一页
末页