摘要: Problem A 每个字符最多出现两次的最长子字符串 思路 双指针,使用一个数组记录每个字符的出现次数,当出现次数大于2时l往左收缩 其余情况往右划 代码 class Solution { public int maximumLengthSubstring(String s) { int n = 阅读全文
posted @ 2024-03-24 21:14 浅花迷人 阅读(2) 评论(0) 推荐(0) 编辑
摘要: Problem A Apple Redistribution into Boxes 思路 求和-算所有苹果的和 然后将箱子从大到小排序 贪心即可 代码 class Solution { public int minimumBoxes(int[] apple, int[] capacity) { in 阅读全文
posted @ 2024-03-17 16:36 浅花迷人 阅读(3) 评论(0) 推荐(0) 编辑
摘要: Problem A Distribute Elements Into Two Arrays I 思路 按照题意模拟即可. 代码 class Solution { public int[] resultArray(int[] nums) { int n = nums.length; int[] ans 阅读全文
posted @ 2024-03-09 22:27 浅花迷人 阅读(1) 评论(0) 推荐(0) 编辑
摘要: Biweekly Contest 91 Problem A Number of Distinct Averages 思路 按照题意模拟即可,最后set的大小就是所求结果 代码 class Solution: def distinctAverages(self, nums: List[int]) -> 阅读全文
posted @ 2022-11-15 13:34 浅花迷人 阅读(25) 评论(0) 推荐(0) 编辑
摘要: Weekly Contest 318 Problem A Apply Operations to an Array 思路 按照题意模拟即可 代码 class Solution: def applyOperations(self, nums: List[int]) -> List[int]: l = 阅读全文
posted @ 2022-11-14 23:11 浅花迷人 阅读(14) 评论(0) 推荐(0) 编辑
摘要: Weekly Contest 317 Problem A Average Value of Even Numbers That Are Divisible by Three 思路 事实上就是求整除6的数的均值 代码 class Solution: def averageValue(self, num 阅读全文
posted @ 2022-11-12 18:14 浅花迷人 阅读(12) 评论(0) 推荐(0) 编辑
摘要: Weekly Contest 316 Problem A Determine if Two Events Have Conflict 思路 先将时间转化为分钟单位,然后根据大小判断有没有交集即可 代码 class Solution: def haveConflict(self, event1: Li 阅读全文
posted @ 2022-11-12 16:11 浅花迷人 阅读(6) 评论(0) 推荐(0) 编辑
摘要: Weekly Contest 315 Problem A Largest Positive Integer That Exists With Its Negative 思路 按照题目要求暴力求一下 代码 class Solution: def findMaxK(self, nums: List[in 阅读全文
posted @ 2022-10-29 22:28 浅花迷人 阅读(18) 评论(0) 推荐(0) 编辑
摘要: Weekly Contest 314 Problem A The Employee That Worked on the Longest Task 思路 按照题目要求遍历一下就行 代码 class Solution: def hardestWorker(self, n: int, logs: Lis 阅读全文
posted @ 2022-10-21 12:37 浅花迷人 阅读(12) 评论(0) 推荐(0) 编辑
摘要: Weekly Contest 313 Problem A Number of Common Factors 思路 数据范围小,直接暴力就完事了 代码 class Solution: def commonFactors(self, a: int, b: int) -> int: t = [] for 阅读全文
posted @ 2022-10-08 22:25 浅花迷人 阅读(15) 评论(0) 推荐(0) 编辑