Skip to content

Commit bffbeb1

Browse files
authored
update: 添加问题“2094.找出3位偶数”的代码和题解(#932)
* fix: ends with space (#931) Signed-off-by: LetMeFly666 <[email protected]> * MGJW: 周报 (#931) Signed-off-by: LetMeFly666 <[email protected]> * words: en (#931) Signed-off-by: LetMeFly666 <[email protected]> * 2094: init (#931) Signed-off-by: LetMeFly666 <[email protected]> * 2094: AC.cpp (#931) Signed-off-by: LetMeFly666 <[email protected]> * 2094: init.Py (#931) Signed-off-by: LetMeFly666 <[email protected]> * 2094: WA.Py -all 0 (#931) Signed-off-by: LetMeFly666 <[email protected]> * 2094: AC.Py (#931) Signed-off-by: LetMeFly666 <[email protected]> * 2094: archive.Java - sleep (#931) Signed-off-by: LetMeFly666 <[email protected]> * tmp: long long ago Signed-off-by: LetMeFly666 <[email protected]> * 2094: RE.java (#931) Signed-off-by: LetMeFly666 <[email protected]> * 2094: AC.cpp - AC,87.27%,80.90% no need to sort (#931) Signed-off-by: LetMeFly666 <[email protected]> * 2094: RE.java (#931) Signed-off-by: LetMeFly666 <[email protected]> * 2094: AC.java - AC,95.41%,76.02% (#931) Signed-off-by: LetMeFly666 <[email protected]> * 2094: Init.Go (#931) Signed-off-by: LetMeFly666 <[email protected]> * 2094: WA.Go (#931) Signed-off-by: LetMeFly666 <[email protected]> * 2094: AC.Go - AC,100.00%,75.00% (#931) Signed-off-by: LetMeFly666 <[email protected]> * update: 添加问题“2094.找出3位偶数”的代码和题解(#932) Signed-off-by: LetMeFly666 <[email protected]> --------- Signed-off-by: LetMeFly666 <[email protected]>
1 parent cb83cd5 commit bffbeb1

20 files changed

+613
-157
lines changed

.gitlog

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
PS F:\OtherApps\Program\Git\Store\Store20_LeetCode> git pull origin master
2+
remote: Enumerating objects: 67621, done.
3+
remote: Counting objects: 100% (67607/67607), done.
4+
remote: Compressing objects: 100% (56572/56572), done.
5+
Receiving objects: 96% (64917/67621), 6.93 MiB | 1.34 MiB/sremote: Total 67621 (delta 8391), reused 65021 (delta 5814), pack-reused 14 (from 1)
6+
Receiving objects: 100% (67621/67621), 7.61 MiB | 941.00 KiB/s, done.
7+
Resolving deltas: 100% (8391/8391), completed with 21 local objects.
8+
From github.com:LetMeFly666/LeetCode
9+
* branch master -> FETCH_HEAD
10+
0b5a1edae4c..9ff5f88f71e master -> origin/master
11+
error: invalid path 'AllProblems/1082.销售分析 I /1082.销售分析 I .md'
12+
error: invalid path 'AllProblems/69.x 的平方根 /69.x 的平方根 .md'
13+
error: invalid path 'AllProblems/69.x 的平方根 /code.2.py'
14+
error: invalid path 'AllProblems/69.x 的平方根 /code.c'
15+
error: invalid path 'AllProblems/69.x 的平方根 /code.cj'
16+
error: invalid path 'AllProblems/69.x 的平方根 /code.cpp'
17+
error: invalid path 'AllProblems/69.x 的平方根 /code.cs'
18+
error: invalid path 'AllProblems/69.x 的平方根 /code.dart'
19+
error: invalid path 'AllProblems/69.x 的平方根 /code.erl'
20+
error: invalid path 'AllProblems/69.x 的平方根 /code.ex'
21+
error: invalid path 'AllProblems/69.x 的平方根 /code.go'
22+
error: invalid path 'AllProblems/69.x 的平方根 /code.java'
23+
error: invalid path 'AllProblems/69.x 的平方根 /code.js'
24+
error: invalid path 'AllProblems/69.x 的平方根 /code.kt'
25+
error: invalid path 'AllProblems/69.x 的平方根 /code.php'
26+
error: invalid path 'AllProblems/69.x 的平方根 /code.py'
27+
error: invalid path 'AllProblems/69.x 的平方根 /code.racket'
28+
error: invalid path 'AllProblems/69.x 的平方根 /code.rb'
29+
error: invalid path 'AllProblems/69.x 的平方根 /code.rs'
30+
error: invalid path 'AllProblems/69.x 的平方根 /code.sc'
31+
error: invalid path 'AllProblems/69.x 的平方根 /code.swift'
32+
error: invalid path 'AllProblems/69.x 的平方根 /code.ts'
33+
error: invalid path 'AllProblems/69.x 的平方根 /titleSlug.txt'
34+
error: invalid path 'AllProblems/LCR 084.全排列 II /LCR 084.全排列 II .md'
35+
error: invalid path 'AllProblems/LCR 084.全排列 II /code.2.py'
36+
error: invalid path 'AllProblems/LCR 084.全排列 II /code.c'
37+
error: invalid path 'AllProblems/LCR 084.全排列 II /code.cpp'
38+
error: invalid path 'AllProblems/LCR 084.全排列 II /code.cs'
39+
error: invalid path 'AllProblems/LCR 084.全排列 II /code.erl'
40+
error: invalid path 'AllProblems/LCR 084.全排列 II /code.ex'
41+
error: invalid path 'AllProblems/LCR 084.全排列 II /code.go'
42+
error: invalid path 'AllProblems/LCR 084.全排列 II /code.java'
43+
error: invalid path 'AllProblems/LCR 084.全排列 II /code.js'
44+
error: invalid path 'AllProblems/LCR 084.全排列 II /code.kt'
45+
error: invalid path 'AllProblems/LCR 084.全排列 II /code.php'
46+
error: invalid path 'AllProblems/LCR 084.全排列 II /code.py'
47+
error: invalid path 'AllProblems/LCR 084.全排列 II /code.racket'
48+
error: invalid path 'AllProblems/LCR 084.全排列 II /code.rb'
49+
error: invalid path 'AllProblems/LCR 084.全排列 II /code.rs'
50+
error: invalid path 'AllProblems/LCR 084.全排列 II /code.sc'
51+
error: invalid path 'AllProblems/LCR 084.全排列 II /code.swift'
52+
error: invalid path 'AllProblems/LCR 084.全排列 II /code.ts'
53+
error: invalid path 'AllProblems/LCR 084.全排列 II /titleSlug.txt'
54+
error: invalid path 'AllProblems/剑指 Offer II 004.只出现一次的数字 /剑指 Offer II 004.只出现一次的数字 .md'
55+
error: invalid path 'AllProblems/剑指 Offer II 084.含有重复元素集合的全排列 /剑指 Offer II 084.含有重复元素集合的全排列 .md'
56+
error: invalid path 'AllProblems/剑指 Offer II 087.复原 IP /剑指 Offer II 087.复原 IP .md'
57+
Updating 0b5a1edae4c..9ff5f88f71e
File renamed without changes.
File renamed without changes.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* @Author: LetMeFly
3+
* @Date: 2025-05-12 10:20:43
4+
* @LastEditors: LetMeFly.xyz
5+
* @LastEditTime: 2025-05-12 22:35:40
6+
*/
7+
#if defined(_WIN32) || defined(__APPLE__)
8+
#include "_[1,2]toVector.h"
9+
#endif
10+
11+
class Solution {
12+
private:
13+
int cnt[10] = {0};
14+
15+
bool isOk(int i) {
16+
if (i % 2) {
17+
return false;
18+
}
19+
int temp[10] = {0};
20+
while (i) {
21+
temp[i % 10]++;
22+
i /= 10;
23+
}
24+
for (int i = 0; i < 10; i++) {
25+
if (cnt[i] < temp[i]) {
26+
return false;
27+
}
28+
}
29+
return true;
30+
}
31+
public:
32+
vector<int> findEvenNumbers(vector<int>& digits) {
33+
for (int d : digits) {
34+
cnt[d]++;
35+
}
36+
vector<int> ans;
37+
for (int i = 100; i < 1000; i++) {
38+
if (isOk(i)) {
39+
ans.push_back(i);
40+
}
41+
}
42+
// sort(ans.begin(), ans.end());
43+
return ans;
44+
}
45+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* @Author: LetMeFly
3+
* @Date: 2025-05-12 21:58:15
4+
* @LastEditors: LetMeFly.xyz
5+
* @LastEditTime: 2025-05-12 22:43:11
6+
*/
7+
package main
8+
9+
func findEvenNumbers(digits []int) []int {
10+
times := make([]int, 10)
11+
for _, d := range digits {
12+
times[d]++
13+
}
14+
ans := make([]int, 0)
15+
for i := 100; i < 1000; i += 2 {
16+
thisTimes := make([]int, 10)
17+
for tmp := i; tmp > 0; tmp /= 10 {
18+
thisTimes[tmp % 10]++
19+
}
20+
ok := true
21+
for j := range times {
22+
if thisTimes[j] > times[j] {
23+
ok = false
24+
break
25+
}
26+
}
27+
if ok {
28+
ans = append(ans, i)
29+
}
30+
}
31+
return ans
32+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* @Author: LetMeFly
3+
* @Date: 2025-05-12 10:20:43
4+
* @LastEditors: LetMeFly.xyz
5+
* @LastEditTime: 2025-05-12 22:38:33
6+
*/
7+
import java.util.Arrays;
8+
import java.util.ArrayList;
9+
10+
class Solution {
11+
public int[] findEvenNumbers(int[] digits) {
12+
int[] times = new int[10];
13+
for (int d : digits) {
14+
times[d]++;
15+
}
16+
List<Integer> ans = new ArrayList<>();
17+
for (int i = 100; i < 1000; i += 2) {
18+
int tmp = i;
19+
int[] thisTimes = new int[10];
20+
while (tmp > 0) {
21+
thisTimes[tmp % 10]++;
22+
tmp /= 10;
23+
}
24+
boolean ok = true;
25+
for (int j = 0; j < 10; j++) {
26+
if (thisTimes[j] > times[j]) {
27+
ok = false;
28+
break;
29+
}
30+
}
31+
if (ok) {
32+
ans.add(i);
33+
}
34+
}
35+
int[] res = new int[ans.size()];
36+
for (int i = 0; i < ans.size(); i++) {
37+
res[i] = ans.get(i);
38+
}
39+
return res;
40+
}
41+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'''
2+
Author: LetMeFly
3+
Date: 2025-05-12 10:20:43
4+
LastEditors: LetMeFly.xyz
5+
LastEditTime: 2025-05-12 13:16:04
6+
'''
7+
from typing import List
8+
9+
class Solution:
10+
def findEvenNumbers(self, digits: List[int]) -> List[int]:
11+
times = [0] * 10
12+
for d in digits:
13+
times[d] += 1
14+
ans = []
15+
for i in range(100, 1000, 2):
16+
thisTimes = [0] * 10
17+
tmp = i
18+
while tmp:
19+
thisTimes[tmp % 10] += 1
20+
tmp //= 10
21+
ok = True
22+
for j in range(10):
23+
if thisTimes[j] > times[j]:
24+
ok = False
25+
break
26+
if ok:
27+
ans.append(i)
28+
return sorted(ans)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@
667667
|2079.给植物浇水|中等|<a href="https://leetcode.cn/problems/watering-plants/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2024/05/08/LeetCode%202079.%E7%BB%99%E6%A4%8D%E7%89%A9%E6%B5%87%E6%B0%B4/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/138581691" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/watering-plants/solutions/2770202/letmefly-2079gei-zhi-wu-jiao-shui-onmo-n-gm33/" target="_blank">LeetCode题解</a>|
668668
|2080.区间内查询数字的频率|中等|<a href="https://leetcode.cn/problems/range-frequency-queries/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2025/02/18/LeetCode%202080.%E5%8C%BA%E9%97%B4%E5%86%85%E6%9F%A5%E8%AF%A2%E6%95%B0%E5%AD%97%E7%9A%84%E9%A2%91%E7%8E%87/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/145700724" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/range-frequency-queries/solutions/3079246/letmefly-2080qu-jian-nei-cha-xun-shu-zi-u33r8/" target="_blank">LeetCode题解</a>|
669669
|2085.统计出现过一次的公共字符串|简单|<a href="https://leetcode.cn/problems/count-common-words-with-one-occurrence/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2024/01/12/LeetCode%202085.%E7%BB%9F%E8%AE%A1%E5%87%BA%E7%8E%B0%E8%BF%87%E4%B8%80%E6%AC%A1%E7%9A%84%E5%85%AC%E5%85%B1%E5%AD%97%E7%AC%A6%E4%B8%B2/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/135560255" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/count-common-words-with-one-occurrence/solutions/2601942/letmefly-2085tong-ji-chu-xian-guo-yi-ci-cdg6x/" target="_blank">LeetCode题解</a>|
670+
|2094.找出3位偶数|简单|<a href="https://leetcode.cn/problems/finding-3-digit-even-numbers/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2025/05/12/LeetCode%202094.%E6%89%BE%E5%87%BA3%E4%BD%8D%E5%81%B6%E6%95%B0/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/147906775" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/finding-3-digit-even-numbers/solutions/3675405/letmefly-2094zhao-chu-3-wei-ou-shu-bian-ncco6/" target="_blank">LeetCode题解</a>|
670671
|2100.适合打劫银行的日子|中等|<a href="https://leetcode.cn/problems/find-good-days-to-rob-the-bank/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2023/09/26/LeetCode%202100.%E9%80%82%E5%90%88%E6%89%93%E5%8A%AB%E9%93%B6%E8%A1%8C%E7%9A%84%E6%97%A5%E5%AD%90/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/133324938" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/find-good-days-to-rob-the-bank/solutions/2460364/letmefly-2100gua-he-da-jie-yin-xing-de-r-aqwp/" target="_blank">LeetCode题解</a>|
671672
|2101.引爆最多的炸弹|中等|<a href="https://leetcode.cn/problems/detonate-the-maximum-bombs/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2024/07/23/LeetCode%202101.%E5%BC%95%E7%88%86%E6%9C%80%E5%A4%9A%E7%9A%84%E7%82%B8%E5%BC%B9/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/140629296" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/detonate-the-maximum-bombs/solutions/2854053/letmefly-2101yin-bao-zui-duo-de-zha-dan-m73kr/" target="_blank">LeetCode题解</a>|
672673
|2105.给植物浇水II|中等|<a href="https://leetcode.cn/problems/watering-plants-ii/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2022/09/05/LeetCode%202105.%E7%BB%99%E6%A4%8D%E7%89%A9%E6%B5%87%E6%B0%B4II/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/126709258" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/watering-plants-ii/solution/by-tisfy-0erl/" target="_blank">LeetCode题解</a>|

0 commit comments

Comments
 (0)