2024/9/15 LeetCode 415周周赛

This commit is contained in:
Cool 2024-09-15 21:48:21 +08:00
parent 396723a171
commit 5b21fc35af
2 changed files with 27 additions and 1 deletions

View File

@ -1,4 +1,4 @@
package com.cool.week414;
package com.cool.week_match.week414;
/**
* Created with IntelliJ IDEA.

View File

@ -0,0 +1,26 @@
package com.cool.week_match.week415;
/**
* Created with IntelliJ IDEA.
*
* @Author: Cool
* @Date: 2024/09/15/21:43
* @Description:
*/
public class Q1 {
public int[] getSneakyNumbers(int[] nums) {
int[] res=new int[2];
int[] arr=new int[nums.length-2];
int index=0;
for(int num:nums){
arr[num]++;
}
for(int i=0;i<arr.length;i++){
if(arr[i]==2){
res[index++]=i;
}
}
return res;
}
}