diff --git a/README.md b/README.md index 8e698e5..a0bb0a8 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@
-
+
diff --git a/assets/data/categories.json b/assets/data/categories.json
index 7c8d4c6..1b0ba92 100644
--- a/assets/data/categories.json
+++ b/assets/data/categories.json
@@ -145,6 +145,12 @@
"path": "./problemset/contains-duplicate/README.md",
"difficulty": "简单"
},
+ {
+ "id": "242",
+ "title": "有效的字母异位词",
+ "path": "./problemset/valid-anagram/README.md",
+ "difficulty": "简单"
+ },
{
"id": "349",
"title": "两个数组的交集",
@@ -425,6 +431,12 @@
"path": "./problemset/isomorphic-strings/README.md",
"difficulty": "简单"
},
+ {
+ "id": "242",
+ "title": "有效的字母异位词",
+ "path": "./problemset/valid-anagram/README.md",
+ "difficulty": "简单"
+ },
{
"id": "541",
"title": "反转字符串 II",
diff --git a/assets/data/topics.json b/assets/data/topics.json
index fe97f74..697daf0 100644
--- a/assets/data/topics.json
+++ b/assets/data/topics.json
@@ -999,6 +999,16 @@
"url": "https://leetcode.cn/problems/invert-binary-tree/description/",
"path": "./problemset/description/README.md"
},
+ {
+ "id": "242",
+ "title": {
+ "cn": "有效的字母异位词",
+ "en": "valid-anagram"
+ },
+ "difficulty": "简单",
+ "url": "https://leetcode.cn/problems/valid-anagram",
+ "path": "./problemset/valid-anagram/README.md"
+ },
{
"id": "273",
"title": {
diff --git a/assets/docs/CATEGORIES.md b/assets/docs/CATEGORIES.md
index b3faccd..c63de1e 100644
--- a/assets/docs/CATEGORIES.md
+++ b/assets/docs/CATEGORIES.md
@@ -32,6 +32,7 @@
| 169. [多数元素](../../problemset/majority-element/README.md) | 简单 |
| 187. [重复的DNA序列](../../problemset/repeated-dna-sequences/README.md) | 中等 |
| 217. [存在重复元素](../../problemset/contains-duplicate/README.md) | 简单 |
+| 242. [有效的字母异位词](../../problemset/valid-anagram/README.md) | 简单 |
| 349. [两个数组的交集](../../problemset/intersection-of-two-arrays/README.md) | 简单 |
| 350. [两个数组的交集 II](../../problemset/intersection-of-two-arrays-ii/README.md) | 简单 |
| 1072. [按列翻转得到最大值等行数](../../problemset/flip-columns-for-maximum-number-of-equal-rows/README.md) | 中等 |
@@ -87,6 +88,7 @@
| 168. [Excel表列名称](../../problemset/excel-sheet-column-title/README.md) | 简单 |
| 171. [Excel 表列序号](../../problemset/excel-sheet-column-number/README.md) | 简单 |
| 205. [同构字符串](../../problemset/isomorphic-strings/README.md) | 简单 |
+| 242. [有效的字母异位词](../../problemset/valid-anagram/README.md) | 简单 |
| 541. [反转字符串 II](../../problemset/reverse-string-ii/README.md) | 简单 |
| 557. [反转字符串中的单词 III](../../problemset/reverse-words-in-a-string-iii/README.md) | 简单 |
| 1016. [子串能表示从 1 到 N 数字的二进制串](../../problemset/binary-string-with-substrings-representing-1-to-n/README.md) | 中等 |
diff --git a/assets/docs/TOPICS.md b/assets/docs/TOPICS.md
index 6bd3616..c585e45 100644
--- a/assets/docs/TOPICS.md
+++ b/assets/docs/TOPICS.md
@@ -200,6 +200,8 @@
[226. 翻转二叉树](../../problemset/description/README.md)
+[242. 有效的字母异位词](../../problemset/valid-anagram/README.md)
+
[273. 整数转换英文表示](../../problemset/integer-to-english-words/README.md)
[278. 第一个错误的版本](../../problemset/first-bad-version/README.md)
diff --git a/problemset/valid-anagram/README.md b/problemset/valid-anagram/README.md
new file mode 100644
index 0000000..a454105
--- /dev/null
+++ b/problemset/valid-anagram/README.md
@@ -0,0 +1,90 @@
+# 有效的字母异位词
+
+> 难度:简单
+>
+> https://leetcode.cn/problems/valid-anagram
+
+## 题目
+
+给定两个字符串 `s` 和 `t` ,编写一个函数来判断 `t` 是否是 `s` 的字母异位词。
+
+注意:若 `s` 和 `t` 中每个字符出现的次数都相同,则称 `s` 和 `t` 互为字母异位词。
+
+
+### 示例 1:
+```javascript
+输入: s = "anagram", t = "nagaram"
+输出: true
+```
+
+### 示例 2:
+```javascript
+输入: s = "rat", t = "car"
+输出: false
+```
+
+## 题解
+
+### TS
+
+```javascript
+export function isAnagram(s: string, t: string): boolean {
+ if (s.length !== t.length) {
+ return false
+ }
+ const mapS = new Map