This commit is contained in:
kkunkka
2025-03-05 12:44:36 +08:00
parent d252ccc790
commit da762c35ed
8 changed files with 165 additions and 50 deletions

5
.idea/codeStyles/codeStyleConfig.xml generated Normal file
View File

@@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>

15
.idea/git_toolbox_prj.xml generated Normal file
View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitToolBoxProjectSettings">
<option name="commitMessageIssueKeyValidationOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
<option name="commitMessageValidationEnabledOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
</component>
</project>

View File

@@ -1,5 +1,9 @@
package com.dota;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
// 按两次 Shift 打开“随处搜索”对话框并输入 `show whitespaces`
// 然后按 Enter 键。现在,您可以在代码中看到空格字符。
public class Main {
@@ -17,3 +21,12 @@ public class Main {
}
}
}
class Solution1 {
public List<List<Integer>> permuteUnique(int[] nums) {
Arrays.sort(nums);
List<List<Integer>> res = new ArrayList<>();
return res;
}
}

View File

@@ -31,28 +31,29 @@ public class Solution {
// 2048. 下一个更大的数值平衡数
public int nextBeautifulNumber(int n) {
while(!ok(++n)) {
while (!ok(++n)) {
}
return n;
}
private boolean ok(int n){
if (n==0) {
private boolean ok(int n) {
if (n == 0) {
return false;
}
int[] dp = new int[10];
while (n!=0) {
int t = n%10;
while (n != 0) {
int t = n % 10;
dp[t]++;
if (dp[t] > t) {
return false;
}
n/=10;
n /= 10;
}
for (int i = 1; i < dp.length; i++) {
if (dp[i]!=0 && dp[i]!=i) {
if (dp[i] != 0 && dp[i] != i) {
return false;
}
}

View File

@@ -0,0 +1,24 @@
package com.dota.arr._2225;
import java.util.ArrayList;
import java.util.List;
//2225. 找出输掉零场或一场比赛的玩家
class Solution {
public List<List<Integer>> findWinners(int[][] matches) {
List<List<Integer>> res = new ArrayList<List<Integer>>();
res.add(new ArrayList<>());
res.add(new ArrayList<>());
int[] book = new int[10001];
for (int[] match : matches) {
book[match[1]]++;
}
for (int i = 0; i < book.length; i++) {
if (book[i] == 1) {
res.get(1).add(i);
}
}
return null;
}
}

View File

@@ -0,0 +1,41 @@
package com.dota.bucket;
import java.util.HashMap;
import java.util.Map;
class Solution {
public boolean containsNearbyAlmostDuplicate(int[] nums, int k, int t) {
Map<Long, Long> map = new HashMap<>();
for (int i = 0; i < nums.length; i++) {
long id = getId(nums[i], t + 1);
if (map.containsKey(id)) {
return true;
}
map.put(id, (long) nums[i]);
if (map.containsKey(id + 1) && Math.abs(map.get(id + 1) - nums[i]) <= t) {
return true;
}
if (map.containsKey(id - 1) && Math.abs(map.get(id - 1) - nums[i]) <= t) {
return true;
}
if (i >= k) {
map.remove(getId(nums[i - k], t + 1));
}
}
return false;
}
public long getId(int x, int w) {
if (x >= 0) {
return x / w;
}
return (x + 1) / w - 1;
}
}

View File

@@ -5,6 +5,19 @@ package com.dota.map;
*/
class Solution {
public int maxDistance(int[] colors) {
int max = 0;
for (int i = 0; i < colors.length; i++) {
for (int j = i+1; j < colors.length; j++) {
if (colors[i] != colors[j]) {
max = Math.max(max, j-i);
}
}
}
return max;
}
public String repeatLimitedString(String s, int repeatLimit) {
var dp = new int[26];
for (char c : s.toCharArray()) {
@@ -27,7 +40,7 @@ class Solution {
break;
}
res.append((char)('a' + j));
res.append((char) ('a' + j));
dp[j]--;
} else {
res.append(String.valueOf((char) ('a' + i)).repeat(dp[i]));

3
src/main/kotlin/A.kt Normal file
View File

@@ -0,0 +1,3 @@
fun main() {
println("123")
}