摘要: LeetCode每日一练 Tree Sum 我的解法 第一次提交 思路: 升序排序输入的数组 找到最小非负数, 然后设置两个指针: left(负数) 和 right(非负数) 因为arr[i] + arr[j] + arr[k] = 0必须的形式一定是[负数, 负数, 非负数(>0)], [负数, 阅读全文
posted @ 2022-05-02 11:34 白い故雪 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 示例 var arr = [["aa","bb","cc"],["aa","bb","cc"],["b","b","v"]]; var hash = {}; var result = []; for(var i = 0, len = arr.length; i < len; i++){ if(!ha 阅读全文
posted @ 2022-05-01 18:31 白い故雪 阅读(379) 评论(0) 推荐(0) 编辑
摘要: Longest Common Prefix 思路 找到原始字符串数组中长度最小的元素作为通用字符串res 遍历字符串数组, 比对元素和res的通用字符串 如果相同, 不做操作 如果不相同, 对res进行切片处理, 跳出当前循环 返回res 代码 /* * @Author: fox * @Date: 阅读全文
posted @ 2022-04-30 17:37 白い故雪 阅读(29) 评论(0) 推荐(0) 编辑
摘要: LeetCode -- Roman to Integer 数组比较法 思路: 将所有罗马数字字符对应的数字存储到数组arr中 循环比较数组元素, 当数组arr[i+1]的值比arr[i]的值大时, 证明是组合罗马字符(后一个罗马字符的数字减去前一个罗马字符对应的数字),先进行减法计算后,再加法赋值到 阅读全文
posted @ 2022-04-29 19:17 白い故雪 阅读(13) 评论(0) 推荐(0) 编辑
摘要: LeetCode -- Integer to Roman 除数计数法 思路: 将所有罗马数字和数字的映射关系存储到对象中 依次使用罗马数字对应的数字数组romanVals与参数数字进行除法操作(获取罗马数字重复次数digit)和求余操作(判断罗马数字的类型) 根据获得到的罗马数字对应的数字value 阅读全文
posted @ 2022-04-29 16:24 白い故雪 阅读(17) 评论(0) 推荐(0) 编辑
摘要: LeetCode每日一练 -- Regular Expression Matching Funny /* * @Author: fox * @Date: 2022-04-26 07:16:38 * @LastEditors: fox * @LastEditTime: 2022-04-26 15:00 阅读全文
posted @ 2022-04-27 16:16 白い故雪 阅读(10) 评论(0) 推荐(0) 编辑
摘要: LeetCode每日一练 -- Container With Most Water Brute Force /* * @Author: fox * @Date: 2022-04-27 09:07:49 * @LastEditors: fox * @LastEditTime: 2022-04-27 1 阅读全文
posted @ 2022-04-27 16:11 白い故雪 阅读(14) 评论(0) 推荐(0) 编辑
摘要: LeetCode每日一练 Palindrome Number /* * @Author: fox * @Date: 2022-04-25 07:29:15 * @LastEditors: fox * @LastEditTime: 2022-04-25 07:45:12 * @Description: 阅读全文
posted @ 2022-04-25 07:47 白い故雪 阅读(2) 评论(0) 推荐(0) 编辑
摘要: LeetCode每日一练 String to Integer (atoi) /* * @Author: fox * @Date: 2022-04-24 07:10:32 * @LastEditors: fox * @LastEditTime: 2022-04-24 08:39:35 * @Descr 阅读全文
posted @ 2022-04-24 08:44 白い故雪 阅读(12) 评论(0) 推荐(0) 编辑
摘要: 取反运算简单使用 参考: https://zhuanlan.zhihu.com/p/261080329 https://blog.csdn.net/qq_19272431/article/details/78564391 // 推断: // 1. 计算机中的位运算都是补码运算,因为数字存储到计算机的 阅读全文
posted @ 2022-04-23 22:13 白い故雪 阅读(60) 评论(0) 推荐(0) 编辑