解题报告

英雄哪里出来11 天前
数据结构·算法·散列表·哈希表·解题报告
《哈希表》K倍区间(解题报告)题目链接:K倍区间计算子数组和能被k整除的子数组数量的算法。通过前缀和与哈希表的结合,高效地统计满足条件的子数组。   需要注意的是,题目要求求的是 k 的非负整数倍,而非整数倍,所以哈希表的值光存储次数是不够的,需要维护一个列表,在枚举到第 i 个元素的时候,在哈希表 hashset[ sum[i]%k ] 的所有列表元素中,统计小于等于 sum[i] 的元素个数进行累加,因为只有小于等于 sum[i] 的值才能保证是 非负整数 倍。
cjh-Java2 年前
算法·解题报告
栈-二叉树的中序遍历/easy给定一个二叉树的根节点 root ,返回 它的 中序 遍历 。示例 1:示例 2:示例 3:提示:进阶: 递归算法很简单,你可以通过迭代算法完成吗?
小白菜又菜2 年前
算法·leetcode·解题报告
Leetcode 299. Bulls and CowsYou are playing the Bulls and Cows game with your friend.
小白菜又菜2 年前
算法·leetcode·解题报告
Leetcode 290. Word PatternGiven a pattern and a string s, find if s follows the same pattern.
小白菜又菜2 年前
算法·leetcode·解题报告
Leetcode 275. H-Index IIGiven an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper and citations is sorted in ascending order, return the researcher’s h-index.
小白菜又菜2 年前
算法·leetcode·解题报告
Leetcode 278. First Bad VersionYou are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version