Skip to content

Commit 7da4e38

Browse files
refactor 358
1 parent 1d7ab48 commit 7da4e38

File tree

1 file changed

+1
-23
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+1
-23
lines changed

src/main/java/com/fishercoder/solutions/_358.java

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,6 @@
66
import java.util.PriorityQueue;
77
import java.util.Queue;
88

9-
/**
10-
* 358. Rearrange String k Distance Apart
11-
*
12-
* Given a non-empty string s and an integer k, rearrange the string such that the same characters are at least distance k from each other.
13-
14-
All input strings are given in lowercase letters. If it is not possible to rearrange the string, return an empty string "".
15-
Example 1:
16-
s = "aabbcc", k = 3
17-
Result: "abcabc"
18-
The same letters are at least distance 3 from each other.
19-
20-
Example 2:
21-
s = "aaabc", k = 3
22-
Answer: ""
23-
It is not possible to rearrange the string.
24-
25-
Example 3:
26-
s = "aaadbbcc", k = 2
27-
Answer: "abacabcd"
28-
Another possible answer is: "abcabcda"
29-
The same letters are at least distance 2 from each other.
30-
*/
319
public class _358 {
3210

3311
public static class Solution1 {
@@ -38,7 +16,7 @@ public String rearrangeString(String s, int k) {
3816
}
3917

4018
PriorityQueue<Map.Entry<Character, Integer>> heap =
41-
new PriorityQueue<>((a, b) -> b.getValue() - a.getValue());
19+
new PriorityQueue<>((a, b) -> b.getValue() - a.getValue());
4220
heap.addAll(count.entrySet());
4321

4422
Queue<Map.Entry<Character, Integer>> waitQueue = new LinkedList<>();

0 commit comments

Comments
 (0)