摘要: 我的 Obsidian 链接图,不知不觉已经使用了一年多了 阅读全文
posted @ 2022-01-02 23:02 吴丹阳-V 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 题目 1137. 第 N 个泰波那契数 解法 跟斐波纳契数列一样的解法 class Solution { /** * @param Integer $n * @return Integer */ function tribonacci($n) { if ($n <= 0) { return 0; } 阅读全文
posted @ 2022-01-02 22:44 吴丹阳-V 阅读(23) 评论(0) 推荐(0) 编辑
摘要: 题目 506. 相对名次 解法 class Solution { /** * @param Integer[] $score * @return String[] */ function findRelativeRanks($score) { if (empty($score)) { return 阅读全文
posted @ 2022-01-02 22:43 吴丹阳-V 阅读(26) 评论(0) 推荐(0) 编辑
摘要: #leetcode 题目 501. 二叉搜索树中的众数 解法 主要是考的一个特性: 二叉搜索树的中序遍历结果是递增的数列 然后就相当于是对一个递增数列求众数的逻辑了 class Solution { private $maxCount = 0; private $base = null; priva 阅读全文
posted @ 2022-01-02 22:42 吴丹阳-V 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 题目 504. 七进制数 解法 进制转换的通用做法 class Solution { /** * @param Integer $num * @return String */ function convertToBase7($num) { $ret = ''; $mul = $num < 0 ? 阅读全文
posted @ 2022-01-02 22:42 吴丹阳-V 阅读(20) 评论(0) 推荐(0) 编辑
摘要: 题目 496. 下一个更大元素 I 解法 遍历一遍 nums2 , 算出来每个元素的下一个最大元素,然后遍历 nums1 取结果 暴力解法: class Solution { /** * @param Integer[] $nums1 * @param Integer[] $nums2 * @ret 阅读全文
posted @ 2022-01-02 22:41 吴丹阳-V 阅读(42) 评论(0) 推荐(0) 编辑
摘要: 题目 500. 键盘行 解法 很简单,首先维护一个字符位置的映射关系,判断每个字符的每一位是否在一行 #哈希表 class Solution { const LINE_CHARS = [ 'q' => 1, 'w' => 1, 'e' => 1, 'r' => 1, 't' => 1, 'y' => 阅读全文
posted @ 2022-01-02 22:41 吴丹阳-V 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 题目 495. 提莫攻击 解法 返回中毒秒数 class Solution { /** * @param Integer[] $timeSeries * @param Integer $duration * @return Integer */ function findPoisonedDurati 阅读全文
posted @ 2022-01-02 22:40 吴丹阳-V 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 题目 492. 构造矩形 解法 class Solution { /** * @param Integer $area * @return Integer[] */ function constructRectangle($area) { if ($area <= 0) { return []; } 阅读全文
posted @ 2022-01-02 22:39 吴丹阳-V 阅读(19) 评论(0) 推荐(0) 编辑
摘要: #leetcode 题目 482. 密钥格式化 解法 用了很多 php 的函数,但是思想就是几个步骤 将源字符串的 - 去掉 从后往前遍历字符串,每 $k 个字符一组,拼接上 - 字符 class Solution { /** * @param String $s * @param Integer 阅读全文
posted @ 2022-01-02 22:38 吴丹阳-V 阅读(34) 评论(0) 推荐(0) 编辑