牛客768685351号
牛客768685351号
全部文章
题解
归档
标签
去牛客网
登录
/
注册
牛客768685351号的博客
全部文章
/ 题解
(共160篇)
题解 | #丑数#
参考:https://blog.nowcoder.net/n/737d5e8a1f5947eba9446b65ee5f8e84 是真的666 class Solution { public: int GetUglyNumber_Solution(int index) { if...
C++
2022-03-06
0
281
题解 | #和为K的连续子数组#
class Solution { public: /** * max length of the subarray sum = k * @param arr int整型vector the array * @param k int整型 target *...
C++
2022-03-06
0
379
题解 | #完全二叉树结点数#
/** struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(...
C++
2022-03-06
0
296
题解 | #最长重复子串#
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param a string字符串 待计算字符串 * @return int整型 */ ...
C++
2022-03-05
0
316
题解 | #第一个只出现一次的字符#
哈希表 class Solution { public: int FirstNotRepeatingChar(string str) { unordered_map<char, int> rec; for(int i=0; i<str.len...
C++
2022-03-05
0
316
题解 | #孩子们的游戏(圆圈中最后剩下的数)#
class Solution { public: int LastRemaining_Solution(int n, int m) { int res = 1; for(int i=1; i<=n; i++){ ...
C++
2022-03-05
0
278
题解 | #旋转数组的最小数字#
采用二分法, 首先判断中心点是在左边的上升区域,还是在右边的上升区域,以此来更新左右指针。 class Solution { public: int minNumberInRotateArray(vector<int> rotateArray) { int lef...
C++
2022-03-05
0
298
题解 | #不相邻最大子序列和#
采用动态规划思路,定义数组dp来记录两种状态,dp长为n,宽为2: (1)dp[i][0]:不以array[i]为结尾的最大子序列和; (2)dp[i][1]:以array[i]为结尾的最大子序列和; 那么有以下转移方程: (1)dp[i][0] = max(dp[i-1][0], dp[i-...
C++
2022-03-05
0
339
题解 | #扑克牌顺子#
class Solution { public: bool IsContinuous( vector<int> numbers ) { int zero_nums = 0; int insert_nums = 0; sort(num...
C++
2022-03-05
0
258
题解 | #矩阵乘法#
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param a int整型vector<vector<>> 第一个矩阵 * @p...
C++
2022-02-27
0
312
首页
上一页
1
2
3
4
5
6
7
8
9
10
下一页
末页