Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita9b314e

Browse files
add 3079
1 parent6a917b3 commita9b314e

File tree

3 files changed

+58
-0
lines changed
  • paginated_contents/algorithms/4th_thousand
  • src

3 files changed

+58
-0
lines changed

‎paginated_contents/algorithms/4th_thousand/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
| 3095|[Shortest Subarray With OR at Least K I](https://leetcode.com/problems/shortest-subarray-with-or-at-least-k-i/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3095.java)|| Easy|
5353
| 3090|[Maximum Length Substring With Two Occurrences](https://leetcode.com/problems/maximum-length-substring-with-two-occurrences/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3090.java)|| Easy|
5454
| 3083|[Existence of a Substring in a String and Its Reverse](https://leetcode.com/problems/existence-of-a-substring-in-a-string-and-its-reverse/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3083.java)|| Easy|
55+
| 3079|[Find the Sum of Encrypted Integers](https://leetcode.com/problems/find-the-sum-of-encrypted-integers/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3079.java)|| Easy|
5556
| 3074|[Apple Redistribution into Boxes](https://leetcode.com/problems/apple-redistribution-into-boxes/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3074.java)|| Easy|
5657
| 3062|[Winner of the Linked List Game](https://leetcode.com/problems/winner-of-the-linked-list-game/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3062.java)|| Easy|
5758
| 3046|[Split the Array](https://leetcode.com/problems/split-the-array/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3046.java)|| Easy|
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
packagecom.fishercoder.solutions.fourththousand;
2+
3+
publicclass_3079 {
4+
publicstaticclassSolution1 {
5+
publicintsumOfEncryptedInt(int[]nums) {
6+
intsum =0;
7+
for (intnum :nums) {
8+
sum +=encrypt(num);
9+
}
10+
returnsum;
11+
}
12+
13+
privateintencrypt(intnum) {
14+
intmax =0;
15+
intdigits =0;
16+
while (num !=0) {
17+
max =Math.max(max,num %10);
18+
num /=10;
19+
digits++;
20+
}
21+
intans =0;
22+
intbase =1;
23+
while (digits >0) {
24+
ans +=base *max;
25+
digits--;
26+
base *=10;
27+
}
28+
returnans;
29+
}
30+
}
31+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
packagecom.fishercoder.fourththousand;
2+
3+
importcom.fishercoder.solutions.fourththousand._3079;
4+
importorg.junit.jupiter.api.BeforeEach;
5+
importorg.junit.jupiter.api.Test;
6+
7+
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
8+
9+
publicclass_3079Test {
10+
privatestatic_3079.Solution1solution1;
11+
12+
@BeforeEach
13+
publicvoidsetup() {
14+
solution1 =new_3079.Solution1();
15+
}
16+
17+
@Test
18+
publicvoidtest1() {
19+
assertEquals(6,solution1.sumOfEncryptedInt(newint[]{1,2,3}));
20+
}
21+
22+
@Test
23+
publicvoidtest2() {
24+
assertEquals(66,solution1.sumOfEncryptedInt(newint[]{10,21,31}));
25+
}
26+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp