摘要:
在JUC中 可以使用synchronized关键字进行加锁 如下所示 Object object = new Object(); synchronized (object){ // TODO } synchronized关键字所加的锁是逐步升级的,顺序是 无锁-> 偏向锁 -> 轻量级锁 -> 重量 阅读全文
摘要:
Problem A 每个字符最多出现两次的最长子字符串 思路 双指针,使用一个数组记录每个字符的出现次数,当出现次数大于2时l往左收缩 其余情况往右划 代码 class Solution { public int maximumLengthSubstring(String s) { int n = 阅读全文
摘要:
Problem A Apple Redistribution into Boxes 思路 求和-算所有苹果的和 然后将箱子从大到小排序 贪心即可 代码 class Solution { public int minimumBoxes(int[] apple, int[] capacity) { in 阅读全文
摘要:
Problem A Distribute Elements Into Two Arrays I 思路 按照题意模拟即可. 代码 class Solution { public int[] resultArray(int[] nums) { int n = nums.length; int[] ans 阅读全文
摘要:
Biweekly Contest 91 Problem A Number of Distinct Averages 思路 按照题意模拟即可,最后set的大小就是所求结果 代码 class Solution: def distinctAverages(self, nums: List[int]) -> 阅读全文
摘要:
Weekly Contest 318 Problem A Apply Operations to an Array 思路 按照题意模拟即可 代码 class Solution: def applyOperations(self, nums: List[int]) -> List[int]: l = 阅读全文
摘要:
Weekly Contest 317 Problem A Average Value of Even Numbers That Are Divisible by Three 思路 事实上就是求整除6的数的均值 代码 class Solution: def averageValue(self, num 阅读全文
摘要:
Weekly Contest 316 Problem A Determine if Two Events Have Conflict 思路 先将时间转化为分钟单位,然后根据大小判断有没有交集即可 代码 class Solution: def haveConflict(self, event1: Li 阅读全文
摘要:
Weekly Contest 315 Problem A Largest Positive Integer That Exists With Its Negative 思路 按照题目要求暴力求一下 代码 class Solution: def findMaxK(self, nums: List[in 阅读全文
摘要:
Weekly Contest 314 Problem A The Employee That Worked on the Longest Task 思路 按照题目要求遍历一下就行 代码 class Solution: def hardestWorker(self, n: int, logs: Lis 阅读全文