kk
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package com.dota;
|
||||
|
||||
import org.apache.commons.collections4.list.TreeList;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class Solution {
|
||||
// 1423. 可获得的最大点数
|
||||
@@ -79,4 +79,43 @@ class Solution2 {
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
class Solution3 {
|
||||
public int[] findEvenNumbers(int[] digits) {
|
||||
int[] dp = new int[10];
|
||||
int cnt = 0;
|
||||
for (int i : digits) {
|
||||
dp[i]++;
|
||||
if (i % 2 == 0) {
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
if (cnt == 0) {
|
||||
return new int[]{};
|
||||
}
|
||||
var set = new HashSet<Integer>();
|
||||
for (int i = 1; i < 10; i++) {
|
||||
if (dp[i] == 0) continue;
|
||||
dp[i]--;
|
||||
for (int j = 0; j < 10; j++) {
|
||||
if (dp[j]==0)continue;
|
||||
dp[j]--;
|
||||
for (int k = 0; k < 10; k++) {
|
||||
if (dp[k]==0 || dp[k] %2==1)continue;
|
||||
set.add(i*100+j*10 + k);
|
||||
}
|
||||
dp[j]++;
|
||||
}
|
||||
dp[i]++;
|
||||
}
|
||||
|
||||
int[] array = new int[set.size()];
|
||||
int index = 0;
|
||||
for (Integer num : set) {
|
||||
array[index++] = num;
|
||||
}
|
||||
Arrays.sort(array);
|
||||
return array;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user