会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
balabalabubalabala
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
6
7
8
9
10
11
12
13
下一页
2022年7月21日
day25
摘要: 1.剑指 Offer 29. 顺时针打印矩阵 方形盘龙问题,思路:在数组外面围一堵矩形的墙,碰到墙就掉头 代码: 1 #include <stdio.h> 2 #include <stdlib.h> 3 #define wall -1 4 #define a 0 5 int main() { 6 i
阅读全文
posted @ 2022-07-21 18:02 balabalahhh
阅读(36)
评论(0)
推荐(0)
2022年7月20日
day24
摘要: 1.剑指 Offer 14- I. 剪绳子 2=1+1,3=1+2, 4 = 2 + 2,5 = 3 + 2,6 = 3 + 3,7 = 3 + 4,8 = 3 + 5 = 3 + 3 + 2,9 = 5 + 4 = 3 + 2 + 4. . . . . . 可以发现,其实从4开始,每个数字都可以由
阅读全文
posted @ 2022-07-20 11:49 balabalahhh
阅读(29)
评论(0)
推荐(0)
2022年7月19日
day23
摘要: 1.剑指 Offer 39. 数组中出现次数超过一半的数字 1)排序后位于中间的数就是我们要求的数 1 class Solution { 2 public: 3 int majorityElement(vector<int>& nums) { 4 sort(nums.begin(),nums.end
阅读全文
posted @ 2022-07-19 12:37 balabalahhh
阅读(23)
评论(0)
推荐(0)
优先队列
摘要: https://blog.csdn.net/Sungree/article/details/100834974 注意:因为是数组表示(有值的区域里没有空缺),所以这个二叉树是完全二叉树 大顶堆: C语言代码 1 #include <stdio.h> 2 #include <stdlib.h> 3 #
阅读全文
posted @ 2022-07-19 11:14 balabalahhh
阅读(31)
评论(0)
推荐(0)
2022年7月18日
day22
摘要: 关于异或:1.任何数和0异或都等于那个数本身(a^0 = a),因为 0^1 = 1, 0^0 = 0 2.任何数和1异或都相当于按位取反,因为 1^1 = 0, 1^0 = 1 3.“还原性”(ps:个人理解): 举个栗子~ :A^B^A= B : A^B = m,m^A = B(m第二次异或同一
阅读全文
posted @ 2022-07-18 12:05 balabalahhh
阅读(39)
评论(0)
推荐(0)
2022年7月17日
day21
摘要: 1.剑指 Offer 15. 二进制中 1 的个数 与1同位与判断最低位是否是1,判断完右移继续判断下一个 1 class Solution { 2 public: 3 int hammingWeight(uint32_t n) { 4 int cnt = 0; 5 while(n){ 6 if(n
阅读全文
posted @ 2022-07-17 10:30 balabalahhh
阅读(27)
评论(0)
推荐(0)
2022年7月16日
day20
摘要: 1.剑指 Offer 07. 重建二叉树 i.根据先序遍历(根节点 + 左子树 + 右子树)和 中序遍历(左子树 + 根节点 + 右子树)求出二叉树的思路就不写了(先序、中序、后序说的是根节点的位置顺序) ii.dfs(preroot,inleft,inright): preroot:先序遍历时的根
阅读全文
posted @ 2022-07-16 17:57 balabalahhh
阅读(32)
评论(0)
推荐(0)
2022年7月15日
day19
摘要: 1.剑指 Offer 64. 求 1 + 2 + … + n 1 class Solution { 2 public: 3 int sumNums(int n) { 4 n > 1 && (n += sumNums(n - 1)); 5 return n; 6 } 7 }; 2.剑指 Offer 6
阅读全文
posted @ 2022-07-15 22:13 balabalahhh
阅读(14)
评论(0)
推荐(0)
2022年7月14日
day18
摘要: 1.剑指 Offer 55 - I. 二叉树的深度 1)dfs 取左、右子树高度的最大值 1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * T
阅读全文
posted @ 2022-07-14 17:30 balabalahhh
阅读(33)
评论(0)
推荐(0)
字符串字典序比较
摘要: C++的 compare函数 为C语言里 strcmp函数 的平替函数 还有一个 < https://blog.csdn.net/qq_38943651/article/details/108302229
阅读全文
posted @ 2022-07-14 12:36 balabalahhh
阅读(59)
评论(0)
推荐(0)
上一页
1
···
6
7
8
9
10
11
12
13
下一页
公告