Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0e228de

Browse files
add 1897
1 parent 13335bc commit 0e228de

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|1897|[Redistribute Characters to Make All Strings Equal](https://leetcode.com/problems/redistribute-characters-to-make-all-strings-equal/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1897.java) ||Easy|String, Greedy|
1112
|1886|[Determine Whether Matrix Can Be Obtained By Rotation](https://leetcode.com/problems/determine-whether-matrix-can-be-obtained-by-rotation/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1886.java) ||Easy|Array|
1213
|1880|[Check if Word Equals Summation of Two Words](https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1880.java) ||Easy|String|
1314
|1877|[Minimize Maximum Pair Sum in Array](https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1877.java) ||Medium|Greedy, Sort|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.fishercoder.solutions;
2+
3+
public class _1897 {
4+
public static class Solution1 {
5+
public boolean makeEqual(String[] words) {
6+
int len = words.length;
7+
int[] counts = new int[26];
8+
for (String word : words) {
9+
for (char c : word.toCharArray()) {
10+
counts[c - 'a']++;
11+
}
12+
}
13+
for (int c : counts) {
14+
if (c % len != 0) {
15+
return false;
16+
}
17+
}
18+
return true;
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)