复盘|第315场周赛
6204. 与对应负数同时存在的最大正整数 https://leetcode.cn/problems/largest-positive-integer-that-exists-with-its-negative/
【哈希表】此题,排序做法O(nlogn),遍历做法O(n),所以一次遍历即可,一边判断-num是否在哈希表里,一边往哈希表里加num。
6205. 反转之后不同整数的数目 https://leetcode.cn/problems/count-number-of-distinct-integers-after-reverse-operations/
【哈希表】哈希表存num和reverse(num),统计length即可。注意到python的int(str(x)[::-1])调用底层c库实现,比手动实现翻转要快。
6219. 反转之后的数字和 https://leetcode.cn/problems/sum-of-number-and-its-reverse/
【模拟】手动实现数字反转。
调库实现数字反转。
2444. 统计定界子数组的数目 https://leetcode.cn/problems/count-subarrays-with-fixed-bounds/
【枚举】将[minK, maxK]范围之外的数作为分割点。在每两个分割点之间,枚举子数组的右端点,minK和maxK最早出现的位置记作idx,idx左侧到左分割点之间都能作为左端点。(代码中手写min/max比调库更快)