06 2021 档案

摘要:338. 比特位计数 class Solution { /** * @param Integer n@returnInteger[]/functioncountBits(n) { ret=[0];for(i = 1; i<=n; $i++) { // 上一个数字 阅读全文
posted @ 2021-06-14 21:04 吴丹阳-V 阅读(46) 评论(0) 推荐(0) 编辑
摘要:话不多说,上代码,差点栽在一个简单题手里,也是我没有想到的 其实呢,我有两种思路 一种就是把小时和分钟的所有位表示的数字都枚举出来,然后最后处理一下最后的输出格式就行了,这个可行,但是废手,而且容易出错 另外一种就是利用递归的方式,计算出每一步的所有可能值 第一种方式:暴力破解,是真的暴力 clas 阅读全文
posted @ 2021-06-13 23:18 吴丹阳-V 阅读(56) 评论(0) 推荐(0) 编辑
摘要:https://leetcode-cn.com/problems/is-subsequence/ 双指针法 <?php class Solution { /** * @param String s@paramStringt * @return Boolean */ function i 阅读全文
posted @ 2021-06-13 14:23 吴丹阳-V 阅读(37) 评论(0) 推荐(0) 编辑
摘要:题目 155. 最小栈 解法 辅助栈 用辅助栈存当前栈中的最小值 class MinStack { private stack=[];privateminStack = []; /** * initialize your data structure here. */ function 阅读全文
posted @ 2021-06-02 18:10 吴丹阳-V 阅读(34) 评论(0) 推荐(0) 编辑
摘要:题目 111. 二叉树的最小深度 解法 跟上一题一样的思路 class Solution { private minDepth=0;/@paramTreeNoderoot * @return Integer */ function minDepth($root) { if ( 阅读全文
posted @ 2021-06-02 18:09 吴丹阳-V 阅读(36) 评论(0) 推荐(0) 编辑
摘要:题目 110. 平衡二叉树 解法 在遍历树的同时,将高度差求出,如果有一个高度差的绝对值大于 1,那么就不用再继续了,可以直接退出返回 false class Solution { private ret=true;/@paramTreeNoderoot * @return 阅读全文
posted @ 2021-06-02 18:08 吴丹阳-V 阅读(18) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示