File tree Expand file tree Collapse file tree 1 file changed +0
-42
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 1 file changed +0
-42
lines changed Original file line number Diff line number Diff line change 6
6
import java .util .List ;
7
7
import java .util .Map ;
8
8
9
- /**
10
- * 451. Sort Characters By Frequency
11
- *
12
- * Given a string, sort it in decreasing order based on the frequency of characters.
13
-
14
- Example 1:
15
-
16
- Input:
17
- "tree"
18
-
19
- Output:
20
- "eert"
21
-
22
- Explanation:
23
- 'e' appears twice while 'r' and 't' both appear once.
24
- So 'e' must appear before both 'r' and 't'. Therefore "eetr" is also a valid answer.
25
-
26
- Example 2:
27
-
28
- Input:
29
- "cccaaa"
30
-
31
- Output:
32
- "cccaaa"
33
-
34
- Explanation:
35
- Both 'c' and 'a' appear three times, so "aaaccc" is also a valid answer.
36
- Note that "cacaca" is incorrect, as the same characters must be together.
37
-
38
- Example 3:
39
-
40
- Input:
41
- "Aabb"
42
-
43
- Output:
44
- "bbAa"
45
-
46
- Explanation:
47
- "bbaA" is also a valid answer, but "Aabb" is incorrect.
48
- Note that 'A' and 'a' are treated as two different characters.
49
-
50
- */
51
9
public class _451 {
52
10
53
11
public static class Solution1 {
You can’t perform that action at this time.
0 commit comments