buptsun
buptsun
全部文章
分类
题解(5)
归档
标签
去牛客网
登录
/
注册
buptsun的博客
全部文章
(共5篇)
题解 | #单链表的排序#
归并排序 1 利用快慢指针寻找中心点 2 递归分成不能再分的小区域 3 建立新链表利用比较法依次插入 /** * struct ListNode { * int val; * struct ListNode *next; * }; */ class Solution { public: ...
C++
链表
2021-10-11
0
233
题解 | #求平方根#
解题思想 整数二分这里需要注意:有可能实际的平方根在mid和mid-1中间,因此需要及时return mid-1,以防错过解的区间。其他地方均按照整数二分方法的模板去做即可。 class Solution { public: /** * * @param x int整型...
C++
2021-09-26
0
265
题解 | #判断链表中是否有环#
快慢指针 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL)...
2021-08-31
0
206
题解 | #二叉树的前/中/后序遍历#
前序 void frontOrder(TreeNode* root) { if(!root) return; if(!root->left&&!root->right) { front...
2021-08-30
0
279
题解 | KMP算法
int kmp(string S, string T) { // write code here int n = S.length(); int m = T.length(); int N = 5e5+10; int ne[N]; int cnt=0...
2021-08-07
0
341