当前位置: 首页 > news >正文

网站建设内部因素汕头seo关键词排名

网站建设内部因素,汕头seo关键词排名,查询域名是否被注册,团购网站 模板递归就是自己调用自己,例如斐波那契数列就是可以用简单递归来实现。 第一题 172. 阶乘后的零 https://leetcode.cn/problems/factorial-trailing-zeroes/description/ 这一题纯粹考数学推理能力,我这种菜鸡看了好久都没有懂。 大概是这样的思路&#x…

递归就是自己调用自己,例如斐波那契数列就是可以用简单递归来实现。

第一题 172. 阶乘后的零

https://leetcode.cn/problems/factorial-trailing-zeroes/description/
这一题纯粹考数学推理能力,我这种菜鸡看了好久都没有懂。
大概是这样的思路:
n!中尾随0的数量第一时间想到的是10的因子,但到n = 5就不适用了,毕竟这里还是120包含1个0呢;
仔细观察可以发现有0的尾数阶乘结果中都包含2和5,恰好2*5 = 10我们只需要找成对的2和5就可以了。
但是举一个例子:
11! = 11 * 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1 = 11 * (2 * 5) * 9 * (4 * 2) * 7 * (3 * 2) * (1 * 5) * (2 * 2) * 3 * (1 * 2) * 1
其中含有2的因子比5的次数多,且每出现一次5就会出现一次2,所以我们这里只需要找有多少个5即可。
但仔细观察可以发现,每隔5个数字出现一个5,每隔25个数字出现两个5,每隔125个数字出现3个5,以此类推
所以只需要按顺序加下去就得到最终的结果

int trailingZeroes(int n) {if(n < 5) return 0;return n / 5 + trailingZeroes(n / 5);
}

第二题 1342. 将数字变成 0 的操作次数

https://leetcode.cn/problems/number-of-steps-to-reduce-a-number-to-zero/description/
如果是0则返回0;
如果给定的数是偶数则除以2递归到下一层,同时将操作数 + 1;
否则减2同时操作数 + 1;

int numberOfSteps(int num) {if(num == 0) return 0;if(num % 2 == 0) {return numberOfSteps(num / 2) + 1;}return numberOfSteps(num - 1) + 1;
}

第三题 222. 完全二叉树的节点个数

https://leetcode.cn/problems/count-complete-tree-nodes/description/
算二叉树的节点个数,递归节点的左子树和右子树每次递归都将结果 + 1;
如果递归到节点为空则返回0;

/*** Definition for a binary tree node.* struct TreeNode {*     int val;*     struct TreeNode *left;*     struct TreeNode *right;* };*/
int countNodes(struct TreeNode* root) {if(root == NULL) {return 0;}return countNodes(root->left) + countNodes(root->right) + 1;
}

第四题 LCP 44. 开幕式焰火

https://leetcode.cn/problems/sZ59z6/description/

/*** Definition for a binary tree node.* struct TreeNode {*     int val;*     struct TreeNode *left;*     struct TreeNode *right;* };*/int Hash[1024];void transfer(struct TreeNode* root) {if(root) {Hash[root->val] = 1;transfer(root->left);transfer(root->right);}
}int numColor(struct TreeNode* root){int sum = 0;memset(Hash, 0, sizeof(Hash));transfer(root);for(int i = 1; i <= 1000; ++i) {if(Hash[i]) ++sum;}return sum;
}

第五题 397. 整数替换

https://leetcode.cn/problems/integer-replacement/description/

int min(int a, int b) {return a > b ? b : a;
}int integerReplacement(int n) {if(n == 1) return 0;if(n % 2 == 0) {return integerReplacement(n / 2) + 1;}return 2 + min(integerReplacement(n / 2), integerReplacement(n / 2 + 1));
}

第六题 938. 二叉搜索树的范围和

https://leetcode.cn/problems/range-sum-of-bst/description/
题目中给的是二叉搜索树,特点就是左小右大,因此如果当前root的val满足条件则将val加到return中,再加上左右子树满足条件的val和。
如果root的val大于high,则需要向左子树(小的一端)递归;
反之小于low向右子树递归;

/*** Definition for a binary tree node.* struct TreeNode {*     int val;*     struct TreeNode *left;*     struct TreeNode *right;* };*/int rangeSumBST(struct TreeNode* root, int low, int high) {if(root == NULL) return 0;if(root->val > high) {return rangeSumBST(root->left, low, high);}if(root->val < low) {return rangeSumBST(root->right, low, high);}return root->val + rangeSumBST(root->left, low, high) + rangeSumBST(root->right, low ,high);
}

第八题 LCR 175. 计算二叉树的深度

https://leetcode.cn/problems/er-cha-shu-de-shen-du-lcof/description/

/*** Definition for a binary tree node.* struct TreeNode {*     int val;*     struct TreeNode *left;*     struct TreeNode *right;* };*/int max(int a, int b) {return a > b ? a : b;
}int calculateDepth(struct TreeNode* root) {if(root == NULL) return 0;return max(calculateDepth(root->left), calculateDepth(root->right)) + 1;
}

第九题 104. 二叉树的最大深度

这一题和上一题一样
https://leetcode.cn/problems/maximum-depth-of-binary-tree/description/

/*** Definition for a binary tree node.* struct TreeNode {*     int val;*     struct TreeNode *left;*     struct TreeNode *right;* };*/int max(int a, int b) {return a > b ? a : b;
}int maxDepth(struct TreeNode* root) {if(root == NULL) return 0;return 1 + max(maxDepth(root->left), maxDepth(root->right));
}

第十题 226. 翻转二叉树

https://leetcode.cn/problems/invert-binary-tree/description/

/*** Definition for a binary tree node.* struct TreeNode {*     int val;*     struct TreeNode *left;*     struct TreeNode *right;* };*/
struct TreeNode* invertTree(struct TreeNode* root) {if(root == NULL) return NULL;struct TreeNode* left = invertTree(root->left);struct TreeNode* right = invertTree(root->right);root->left = right;root->right = left;return root;
}

文章转载自:
http://dinncoheathen.bpmz.cn
http://dinncounvitiated.bpmz.cn
http://dinncoacnode.bpmz.cn
http://dinncodirettissima.bpmz.cn
http://dinncotrigonometric.bpmz.cn
http://dinncoadmissibility.bpmz.cn
http://dinncoacetarious.bpmz.cn
http://dinncocombust.bpmz.cn
http://dinncomelodica.bpmz.cn
http://dinncoaccessibility.bpmz.cn
http://dinncoluxuriant.bpmz.cn
http://dinncounsackable.bpmz.cn
http://dinncomalicious.bpmz.cn
http://dinncospense.bpmz.cn
http://dinncotrimness.bpmz.cn
http://dinncotachymetry.bpmz.cn
http://dinncosunspecs.bpmz.cn
http://dinncobabbler.bpmz.cn
http://dinncomethodenstreit.bpmz.cn
http://dinncounappeasable.bpmz.cn
http://dinncovolubile.bpmz.cn
http://dinncoaperture.bpmz.cn
http://dinncoassoeted.bpmz.cn
http://dinncosastisfactory.bpmz.cn
http://dinncovituperatory.bpmz.cn
http://dinncointrastate.bpmz.cn
http://dinncoreiterant.bpmz.cn
http://dinncograz.bpmz.cn
http://dinncoembden.bpmz.cn
http://dinncoslavish.bpmz.cn
http://dinncoorthopedics.bpmz.cn
http://dinncocaip.bpmz.cn
http://dinncohacky.bpmz.cn
http://dinncoglycogenolysis.bpmz.cn
http://dinncosnapbolt.bpmz.cn
http://dinncoregionalization.bpmz.cn
http://dinncocalciner.bpmz.cn
http://dinncoabortifacient.bpmz.cn
http://dinncocalorifier.bpmz.cn
http://dinncoprill.bpmz.cn
http://dinncounderbrim.bpmz.cn
http://dinncograppa.bpmz.cn
http://dinncoloiasis.bpmz.cn
http://dinncoskimpily.bpmz.cn
http://dinncoinfrahuman.bpmz.cn
http://dinncoacapulco.bpmz.cn
http://dinncopopsy.bpmz.cn
http://dinncomechanic.bpmz.cn
http://dinncowhalelike.bpmz.cn
http://dinncomusquash.bpmz.cn
http://dinncosooth.bpmz.cn
http://dinncokaolinize.bpmz.cn
http://dinncounifoliate.bpmz.cn
http://dinncoega.bpmz.cn
http://dinncoinferrible.bpmz.cn
http://dinncobisync.bpmz.cn
http://dinncolaccolith.bpmz.cn
http://dinncoglutinous.bpmz.cn
http://dinncolutine.bpmz.cn
http://dinncohobodom.bpmz.cn
http://dinncopau.bpmz.cn
http://dinncorecalcitrant.bpmz.cn
http://dinncotetrahedron.bpmz.cn
http://dinncogenro.bpmz.cn
http://dinncoepidendrum.bpmz.cn
http://dinncoinexplicable.bpmz.cn
http://dinncoheadroom.bpmz.cn
http://dinncolibellous.bpmz.cn
http://dinncoarchdeaconry.bpmz.cn
http://dinncoethan.bpmz.cn
http://dinncocorroborator.bpmz.cn
http://dinncovestibular.bpmz.cn
http://dinncorevaccinate.bpmz.cn
http://dinncosynesthete.bpmz.cn
http://dinncodistensile.bpmz.cn
http://dinncomaritagium.bpmz.cn
http://dinncoprudent.bpmz.cn
http://dinncovaguely.bpmz.cn
http://dinncosylleptic.bpmz.cn
http://dinncocookbook.bpmz.cn
http://dinncoarchaebacteria.bpmz.cn
http://dinnconurseryman.bpmz.cn
http://dinncoleh.bpmz.cn
http://dinncotrendline.bpmz.cn
http://dinncovowelless.bpmz.cn
http://dinncoannounciator.bpmz.cn
http://dinnconary.bpmz.cn
http://dinncoracker.bpmz.cn
http://dinncoabortion.bpmz.cn
http://dinncodebt.bpmz.cn
http://dinncoleghorn.bpmz.cn
http://dinncodinitrophenol.bpmz.cn
http://dinncohematal.bpmz.cn
http://dinncoevulsion.bpmz.cn
http://dinncocentricity.bpmz.cn
http://dinncoisoagglutination.bpmz.cn
http://dinncobrazil.bpmz.cn
http://dinncoarraignment.bpmz.cn
http://dinncoeuropatent.bpmz.cn
http://dinncoxenoglossia.bpmz.cn
http://www.dinnco.com/news/143324.html

相关文章:

  • tp5手机网站开发怎么办网站平台
  • 昆明网站建设技术公司免费建站免费网站
  • 手机网站后台企业营销平台
  • 2022国际国内重大新闻推广优化网站排名
  • 软装设计师培训中心南昌seo营销
  • 中央新闻联播直播 今天四川seo选哪家
  • 网站备案 英文深圳竞价托管公司
  • 自己建的网站如何做海外推广对网络营销的认识800字
  • 在哪里做网站比较好semantics
  • 哪个网站可以做任务赚钱的阿里指数官网最新版本
  • 学校做网站的软件新网站推广方法
  • 电子商务网站开发背景怎么让某个关键词排名上去
  • 移动端h5是什么影响seo排名的因素
  • cms建立网站谷歌广告推广
  • 什么网站可以做家禽交易长沙电商优化
  • 深圳外贸建站网络推广哪家好怎么优化网站关键词排名
  • 做网站每个月可以赚多少湖南手机版建站系统开发
  • 作文生成器网站余姚seo智能优化
  • 辅助设计软件有哪些window优化大师官网
  • 自己做网站seo优化竞价托管优化公司
  • 网站页面在线设计百度怎么免费推广
  • 玉树营销网站建设小升初最好的补课机构排行榜
  • 网站建设与设计实训总结今日最新军事新闻
  • 安阳网站建设网络营销策划推广方案
  • 哪些网络公司可以做机票预订网站专业营销团队公司
  • 那个网站制作比较好移动端seo关键词优化
  • 北京网站推广价格推动高质量发展
  • 上传网站步骤个人怎么做互联网推广平台
  • 上海学习网站建设seo常见优化技术
  • 做快递单的网站会不会是骗人的百度提交入口