We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3261b01 commit 6a312bbCopy full SHA for 6a312bb
2018.11.29-leetcode443/Avalon.md
@@ -0,0 +1,17 @@
1
+public static int compress(char[] chars) {
2
+ Map<Character, String> map = new LinkedHashMap();
3
+ int len = chars.length;
4
+ for (int i = 0; i<len;i++){
5
+ if (map.containsKey(chars[i])){
6
+ map.put(chars[i],String.valueOf(Integer.parseInt(map.get(chars[i])) + 1));
7
+ }else map.put(chars[i],"1");
8
+ }
9
+ int num = 0;
10
+ for (Map.Entry<Character, String> entry : map.entrySet()) {
11
+ num++;
12
+ if (!entry.getValue().equals("1")){
13
+ num += entry.getValue().toCharArray().length ;
14
15
16
+ return num;
17
0 commit comments