JZ46 孩子们的游戏 Solution 模拟法 123456789101112131415161718192021class Solution {public: int LastRemaining_Solution(int n, int m) { if (n <= 0 || m < 0) return -1; // 利用数组模拟环删除过程 2021-10-10 algo 数学 nowcoder
JZ45 扑克牌顺子 Solution 12345678910111213141516class Solution {public: bool IsContinuous( vector<int> numbers ) { if (numbers.size() < 5) return false; vector<int> recor 2021-10-10 algo nowcoder 数组
JZ44 翻转单词序列 Solution 12345678910111213141516class Solution {public: string ReverseSentence(string str) { string res = "", cur = ""; for (char c : str) { 2021-10-10 algo 字符串 nowcoder
JZ43 左旋转字符串 Solution 拼接再截取 12345678910class Solution {public: string LeftRotateString(string str, int n) { int len = str.size(); if (len == 0 || n <= 0) return str; n %= 2021-10-10 algo 字符串 nowcoder
JZ42 和为S的两个数字 Solution 双指针 1234567891011121314151617181920212223242526class Solution {public: vector<int> FindNumbersWithSum(vector<int> array,int sum) { vector<int> res; 2021-10-10 algo nowcoder 数组
JZ41 和为S的连续正数序列 Solution 暴力法 123456789101112131415161718192021222324class Solution {public: vector<vector<int> > FindContinuousSequence(int sum) { vector<vector<int>> 2021-10-10 algo nowcoder 数组
JZ40 数组中只出现一次的两个数字 Solution 位运算 123456789101112131415161718192021222324252627282930class Solution {public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param array int整型vector * 2021-10-08 algo 位运算 nowcoder
JZ39 平衡二叉树 Solution 1234567891011121314151617class Solution {public: bool IsBalanced_Solution(TreeNode* pRoot) { return getDepth(pRoot) != -1; } int getDepth(TreeNode* root 2021-10-08 algo 二叉树 nowcoder
JZ38 二叉树的深度 Solution 123456789101112131415161718/*struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) { }};*/class 2021-10-08 algo 二叉树 nowcoder
JZ37 数字在升序数组中出现的次数 Solution 二分查找 12345678910111213141516171819202122232425262728293031323334353637383940class Solution {public: int GetNumberOfK(vector<int> data ,int k) { if (data.size() 2021-10-08 algo nowcoder 数组