今日的每日一题不会做
This commit is contained in:
parent
75e19bf6b5
commit
f4fef28d50
|
@ -7,7 +7,9 @@ import org.junit.Test;
|
||||||
*
|
*
|
||||||
* @Author: Cool
|
* @Author: Cool
|
||||||
* @Date: 2024/08/25/1:43
|
* @Date: 2024/08/25/1:43
|
||||||
* @Description:
|
* DayNumber 1
|
||||||
|
* Hard 1
|
||||||
|
* @Remark 8.25做的
|
||||||
*/
|
*/
|
||||||
public class LeetCode20240824 {
|
public class LeetCode20240824 {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.cool.one_question_per_day;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with IntelliJ IDEA.
|
||||||
|
*
|
||||||
|
* @Author: Cool
|
||||||
|
* @Date: 2024/08/25/19:12
|
||||||
|
* DayNumber 2
|
||||||
|
* Hard 2
|
||||||
|
*/
|
||||||
|
public class LeetCode20240825 {
|
||||||
|
|
||||||
|
public boolean canPartitionKSubsets(int[] nums, int k) {
|
||||||
|
int sum = Arrays.stream(nums).sum();
|
||||||
|
if(sum%k!=0){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int average=sum/k;
|
||||||
|
Arrays.sort(nums);
|
||||||
|
int n = nums.length;
|
||||||
|
if (nums[n - 1] > average) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue