offers++
offers++
全部文章
分类
题解(3)
归档
标签
去牛客网
登录
/
注册
offers++的博客
全部文章
(共8篇)
题解 | #字符串出现次数的TopK问题#
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * return topK string * @param strings string字符串vector ...
2024-03-10
0
59
题解 | #重排链表#快慢指针分为前后半段,然后翻转后半段
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} ...
2023-04-01
0
179
题解 | #输出二叉树的右视图#
// 构造二叉树 + 层次遍历 class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定...
C++
二叉树
2022-10-28
0
198
题解 | #旋转数组的最小数字#
说明: 这道题最佳方法时间复杂度为o(n),大家二分方法时间复杂度分析不对 class Solution { public: int minNumberInRotateArray(vect...
C++
数组
2022-10-23
0
167
题解 | #单链表的排序#
提供两种方法 方法一:归并排序 ListNode* sortInList(ListNode* head) { if(!head || !head...
C++
链表
2022-10-22
0
195
借助HashMap记录之前的数之和
借助HashMap记录之前的数之和时间复杂度:o(n) 空间复杂度:o(n) import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc=new Scann...
2020-03-13
8
1016
minimum-depth-of-binary-tree
//方法-: class Solution { public: int run(TreeNode *root) { &...
2019-08-05
1
739
二叉树的镜像
方法有二: 其一:先序遍历,第一次经过结点时交换左右孩子 void Mirror(TreeNode *pRoot) { if(!pRoot) return; swap(pRoot-...
2019-08-01
0
552