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

Commitc805826

Browse files
add 820
1 parentec5a38e commitc805826

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

‎README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,8 @@ _If you like this project, please leave me a star._ ★
421421
|832|[Flipping an Image](https://leetcode.com/problems/flipping-an-image/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_832.java)||Easy|
422422
|830|[Positions of Large Groups](https://leetcode.com/problems/positions-of-large-groups/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_830.java)||Easy|
423423
|824|[Goat Latin](https://leetcode.com/problems/goat-latin/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_824.java)||Easy|
424-
|821|[Shortest Distance to a Character](https://leetcode.com/problems/shortest-distance-to-a-character/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_821.java)||Easy|
424+
|821|[Shortest Distance to a Character](https://leetcode.com/problems/shortest-distance-to-a-character/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_821.java)||Easy|
425+
|820|[Short Encoding of Words](https://leetcode.com/problems/short-encoding-of-words/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_820.java)||Medium|
425426
|819|[Most Common Word](https://leetcode.com/problems/most-common-word/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_819.java) | |Easy| HashMap
426427
|814|[Binary Tree Pruning](https://leetcode.com/problems/binary-tree-pruning/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_814.java) | |Medium| recursion, DFS
427428
|811|[Subdomain Visit Count](https://leetcode.com/problems/subdomain-visit-count/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_811.java) | |Easy| HashMap
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
packagecom.fishercoder.solutions;
2+
3+
importjava.util.Arrays;
4+
5+
publicclass_820 {
6+
publicstaticclassSolution1 {
7+
publicintminimumLengthEncoding(String[]words) {
8+
Arrays.sort(words, (a,b) ->a.length() -b.length());
9+
boolean[]removed =newboolean[words.length];
10+
for (intj =words.length -2;j >=0;j--) {
11+
for (inti =j +1;i <words.length;i++) {
12+
if (!removed[i]) {
13+
if (words[i].substring(words[i].length() -words[j].length()).equals(words[j])) {
14+
removed[j] =true;
15+
break;
16+
}
17+
}
18+
}
19+
}
20+
intlen =0;
21+
for (inti =0;i <words.length;i++) {
22+
if (!removed[i]) {
23+
len +=words[i].length();
24+
len++;
25+
}
26+
}
27+
returnlen;
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp