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 9639748 commit 16119e6Copy full SHA for 16119e6
one-question-per-day/20200328/solution1.js
@@ -0,0 +1,32 @@
1
+/**
2
+ * https://leetcode-cn.com/problems/short-encoding-of-words/
3
+ *
4
+ * 820. 单词的压缩编码
5
6
+ * Medium
7
8
+ * 96ms 89.47%
9
+ * 43mb 100.00%
10
11
+ * 1、哈希表
12
+ * 2、后缀
13
+ */
14
+const minimumLengthEncoding = words => {
15
+ const record = new Set();
16
+
17
+ for (let i = 0; i < words.length; i++) {
18
+ record.add(words[i]);
19
+ }
20
21
+ for (const values of record.values()) {
22
+ for (let i = 1; i < values.length; i++) {
23
+ record.delete(values.slice(i));
24
25
26
27
+ let ans = 0;
28
29
+ ans += values.length + 1;
30
31
+ return ans;
32
+}
0 commit comments