剑指 Offer 43. 1~n 整数中 1 出现的次数(困难)
摘要:题目:  
推荐(0) 编辑
剑指 Offer 65. 不用加减乘除做加法(简单)
摘要:题目:  ``` class Solution { public: int add(int a, int b) {
阅读全文
posted @
2023-09-04 20:08
孜孜不倦fly
阅读(2)
推荐(0) 编辑
剑指 Offer 15. 二进制中1的个数(简单)
摘要:题目:  ``` class Solution { public: int hammingWeight(uint32
阅读全文
posted @
2023-09-04 19:32
孜孜不倦fly
阅读(3)
推荐(0) 编辑
剑指 Offer 62. 圆圈中最后剩下的数字(简单)
摘要:题目:  
推荐(0) 编辑
剑指 Offer 57 - II. 和为s的连续正数序列(简单)
摘要:题目:  ``` class Solution { public: vector> findContinuousS
阅读全文
posted @
2023-09-03 11:22
孜孜不倦fly
阅读(3)
推荐(0) 编辑
剑指 Offer 39. 数组中出现次数超过一半的数字(简单)
摘要:题目:  ``` class Solution { public: int majorityElement(vec
阅读全文
posted @
2023-09-03 10:09
孜孜不倦fly
阅读(1)
推荐(0) 编辑
剑指 Offer 44. 数字序列中某一位的数字(中等)
摘要:题目: class Solution { //本题单纯找规律,要注意通过n%digits来判断有几个位数为digits的数 public: int findNthDigit(int n) { long base = 9, digits = 1; //digits代表位数 while(n-base*d
阅读全文
posted @
2023-09-02 21:04
孜孜不倦fly
阅读(2)
推荐(0) 编辑
剑指 Offer 42. 连续子数组的最大和(简单)
摘要:题目:  ``` class Solution { public: int maxSubArray(vector&
阅读全文
posted @
2023-09-02 19:54
孜孜不倦fly
阅读(3)
推荐(0) 编辑
剑指 Offer 14- II. 剪绳子 II(中等)
摘要:题目:  ``` class Solution { //本题用贪心算法,拆成尽可能多的3且不可以出现长度为1的小段
阅读全文
posted @
2023-09-01 20:26
孜孜不倦fly
阅读(2)
推荐(0) 编辑
剑指 Offer 14- I. 剪绳子(中等)
摘要:题目:  ``` class Solution { public: int cuttingRope(int n)
阅读全文
posted @
2023-08-31 21:53
孜孜不倦fly
阅读(3)
推荐(0) 编辑
剑指 Offer 66. 构建乘积数组(中等)
摘要:题目: class Solution { public: vector<int> constructArr(vector<int>& a) { int len = a.size(); if(len==0) return {}; vector<int> b(len, 1); for(int i=1;i
阅读全文
posted @
2023-08-31 20:45
孜孜不倦fly
阅读(7)
推荐(0) 编辑
剑指 Offer 56 - II. 数组中数字出现的次数 II(中等)
摘要:题目:  ``` class Solution { public: int singleNumber(vector&
阅读全文
posted @
2023-08-30 21:40
孜孜不倦fly
阅读(3)
推荐(0) 编辑
剑指 Offer 56 - I. 数组中数字出现的次数(中等)
摘要:题目:  ``` class Solution { public: vector singleNumbers(vec
阅读全文
posted @
2023-08-30 20:52
孜孜不倦fly
阅读(3)
推荐(0) 编辑
剑指 Offer 60. n个骰子的点数(中等)
摘要:题目: class Solution { public: vector<double> dicesProbability(int n) { vector<double> dp(6, 1.0/6.0); //dp[j]表示和为j时的概率,这里j=6是因为这是第一个骰子,骰子增多j也会改变 for(in
阅读全文
posted @
2023-08-29 22:20
孜孜不倦fly
阅读(7)
推荐(0) 编辑
剑指 Offer 49. 丑数(中等)
摘要:题目:  ``` class Solution { public: int nthUglyNumber(int n)
阅读全文
posted @
2023-08-29 21:00
孜孜不倦fly
阅读(5)
推荐(0) 编辑
剑指 Offer 19. 正则表达式匹配(困难)
摘要:题目: class Solution { public: bool isMatch(string s, string p) { int m = s.size()+1, n = p.size()+1; vector<vector<bool>> dp(m, vector<bool>(n, false))
阅读全文
posted @
2023-08-28 22:57
孜孜不倦fly
阅读(4)
推荐(0) 编辑
剑指 Offer 10- II. 青蛙跳台阶问题(简单)
摘要:题目:  ``` class Solution { public: int numWays(int n) { vec
阅读全文
posted @
2023-08-28 21:42
孜孜不倦fly
阅读(17)
推荐(0) 编辑
剑指 Offer 61. 扑克牌中的顺子(简单)
摘要:题目:  ``` class Solution { public: bool isStraight(vector&
阅读全文
posted @
2023-08-27 20:44
孜孜不倦fly
阅读(7)
推荐(0) 编辑
剑指 Offer 40. 最小的k个数(简单)
摘要:题目:  ``` class Solution { public: vector getLeastNumbers(v
阅读全文
posted @
2023-08-27 20:11
孜孜不倦fly
阅读(6)
推荐(0) 编辑
剑指 Offer 17. 打印从1到最大的n位数(简单)
摘要:题目:  ``` class Solution { public: vector printNumbers(int
阅读全文
posted @
2023-08-27 19:52
孜孜不倦fly
阅读(3)
推荐(0) 编辑