diff --git a/solution/0000-0099/0024.Swap Nodes in Pairs/README_EN.md b/solution/0000-0099/0024.Swap Nodes in Pairs/README_EN.md index 9d8f91b526e06..f2a3dc01f612a 100644 --- a/solution/0000-0099/0024.Swap Nodes in Pairs/README_EN.md +++ b/solution/0000-0099/0024.Swap Nodes in Pairs/README_EN.md @@ -21,25 +21,40 @@ tags:

 

Example 1:

- -
-Input: head = [1,2,3,4]
-Output: [2,1,4,3]
-
+ +
+

Input: head = [1,2,3,4]

+ +

Output: [2,1,4,3]

+ +

Explanation:

+ +

+

Example 2:

-
-Input: head = []
-Output: []
-
+
+

Input: head = []

+ +

Output: []

+

Example 3:

-
-Input: head = [1]
-Output: [1]
-
+
+

Input: head = [1]

+ +

Output: [1]

+
+ +

Example 4:

+ +
+

Input: head = [1,2,3]

+ +

Output: [2,1,3]

+

 

Constraints:

diff --git a/solution/0000-0099/0049.Group Anagrams/README_EN.md b/solution/0000-0099/0049.Group Anagrams/README_EN.md index acfbcd0b85a09..5bb59726810d8 100644 --- a/solution/0000-0099/0049.Group Anagrams/README_EN.md +++ b/solution/0000-0099/0049.Group Anagrams/README_EN.md @@ -19,21 +19,41 @@ tags: -

Given an array of strings strs, group the anagrams together. You can return the answer in any order.

- -

An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.

+

Given an array of strings strs, group the anagrams together. You can return the answer in any order.

 

Example 1:

-
Input: strs = ["eat","tea","tan","ate","nat","bat"]
-Output: [["bat"],["nat","tan"],["ate","eat","tea"]]
-

Example 2:

-
Input: strs = [""]
-Output: [[""]]
-

Example 3:

-
Input: strs = ["a"]
-Output: [["a"]]
-
+ +
+

Input: strs = ["eat","tea","tan","ate","nat","bat"]

+ +

Output: [["bat"],["nat","tan"],["ate","eat","tea"]]

+ +

Explanation:

+ + +
+ +

Example 2:

+ +
+

Input: strs = [""]

+ +

Output: [[""]]

+
+ +

Example 3:

+ +
+

Input: strs = ["a"]

+ +

Output: [["a"]]

+
+

 

Constraints:

diff --git a/solution/0000-0099/0071.Simplify Path/README.md b/solution/0000-0099/0071.Simplify Path/README.md index 6551d3fe9d4d2..7a812678dee08 100644 --- a/solution/0000-0099/0071.Simplify Path/README.md +++ b/solution/0000-0099/0071.Simplify Path/README.md @@ -17,11 +17,18 @@ tags: -

给你一个字符串 path ,表示指向某一文件或目录的 Unix 风格 绝对路径 (以 '/' 开头),请你将其转化为更加简洁的规范路径。

+

给你一个字符串 path ,表示指向某一文件或目录的 Unix 风格 绝对路径 (以 '/' 开头),请你将其转化为 更加简洁的规范路径

-

在 Unix 风格的文件系统中,一个点(.)表示当前目录本身;此外,两个点 (..) 表示将目录切换到上一级(指向父目录);两者都可以是复杂相对路径的组成部分。任意多个连续的斜杠(即,'//')都被视为单个斜杠 '/' 。 对于此问题,任何其他格式的点(例如,'...')均被视为文件/目录名称。

+

在 Unix 风格的文件系统中规则如下:

-

请注意,返回的 规范路径 必须遵循下述格式:

+ + +

返回的 简化路径 必须遵循下述格式:

 

diff --git a/solution/0400-0499/0411.Minimum Unique Word Abbreviation/README_EN.md b/solution/0400-0499/0411.Minimum Unique Word Abbreviation/README_EN.md index b212be8d5b140..039935058905c 100644 --- a/solution/0400-0499/0411.Minimum Unique Word Abbreviation/README_EN.md +++ b/solution/0400-0499/0411.Minimum Unique Word Abbreviation/README_EN.md @@ -4,6 +4,7 @@ difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/0400-0499/0411.Minimum%20Unique%20Word%20Abbreviation/README_EN.md tags: - Bit Manipulation + - Array - String - Backtracking --- diff --git a/solution/0700-0799/0733.Flood Fill/README.md b/solution/0700-0799/0733.Flood Fill/README.md index 8f767ef589da4..e428216c351e4 100644 --- a/solution/0700-0799/0733.Flood Fill/README.md +++ b/solution/0700-0799/0733.Flood Fill/README.md @@ -23,7 +23,7 @@ tags:

你也被给予三个整数 srsccolor 。你应该从像素 image[sr][sc] 开始对图像进行 上色填充

-

为了完成 上色工作 ,从初始像素开始,记录初始坐标的 上下左右四个方向上 像素值与初始坐标相同的相连像素点,接着再记录这四个方向上符合条件的像素点与他们对应 四个方向上 像素值与初始坐标相同的相连像素点,……,重复该过程。将所有有记录的像素点的颜色值改为 color 。

+

为了完成 上色工作,从初始像素开始,记录初始坐标的 上下左右四个方向上 相邻且同色的像素点,接着再记录与这些像素点相邻且同色的新像素点,……,重复该过程。将所有有记录的像素点的颜色值改为 color

最后返回 经过上色渲染后的图像 

diff --git a/solution/0800-0899/0884.Uncommon Words from Two Sentences/README.md b/solution/0800-0899/0884.Uncommon Words from Two Sentences/README.md index 5e9167837601e..d2a7051f4907c 100644 --- a/solution/0800-0899/0884.Uncommon Words from Two Sentences/README.md +++ b/solution/0800-0899/0884.Uncommon Words from Two Sentences/README.md @@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/0800-0899/0884.Un tags: - 哈希表 - 字符串 + - 计数 --- diff --git a/solution/0800-0899/0884.Uncommon Words from Two Sentences/README_EN.md b/solution/0800-0899/0884.Uncommon Words from Two Sentences/README_EN.md index 8c5c9a9410380..178d6d746c811 100644 --- a/solution/0800-0899/0884.Uncommon Words from Two Sentences/README_EN.md +++ b/solution/0800-0899/0884.Uncommon Words from Two Sentences/README_EN.md @@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/0800-0899/0884.Un tags: - Hash Table - String + - Counting --- @@ -25,12 +26,25 @@ tags:

 

Example 1:

-
Input: s1 = "this apple is sweet", s2 = "this apple is sour"
-Output: ["sweet","sour"]
-

Example 2:

-
Input: s1 = "apple apple", s2 = "banana"
-Output: ["banana"]
-
+ +
+

Input: s1 = "this apple is sweet", s2 = "this apple is sour"

+ +

Output: ["sweet","sour"]

+ +

Explanation:

+ +

The word "sweet" appears only in s1, while the word "sour" appears only in s2.

+
+ +

Example 2:

+ +
+

Input: s1 = "apple apple", s2 = "banana"

+ +

Output: ["banana"]

+
+

 

Constraints:

diff --git a/solution/1000-1099/1055.Shortest Way to Form String/README.md b/solution/1000-1099/1055.Shortest Way to Form String/README.md index 5758f5ec5725f..8134b32effe24 100644 --- a/solution/1000-1099/1055.Shortest Way to Form String/README.md +++ b/solution/1000-1099/1055.Shortest Way to Form String/README.md @@ -6,6 +6,7 @@ tags: - 贪心 - 双指针 - 字符串 + - 二分查找 --- diff --git a/solution/1000-1099/1055.Shortest Way to Form String/README_EN.md b/solution/1000-1099/1055.Shortest Way to Form String/README_EN.md index c15d06aae9335..38ec03f24a9a1 100644 --- a/solution/1000-1099/1055.Shortest Way to Form String/README_EN.md +++ b/solution/1000-1099/1055.Shortest Way to Form String/README_EN.md @@ -6,6 +6,7 @@ tags: - Greedy - Two Pointers - String + - Binary Search --- diff --git a/solution/1000-1099/1078.Occurrences After Bigram/README.md b/solution/1000-1099/1078.Occurrences After Bigram/README.md index 08b432a41fb2a..a89a520d96bee 100644 --- a/solution/1000-1099/1078.Occurrences After Bigram/README.md +++ b/solution/1000-1099/1078.Occurrences After Bigram/README.md @@ -48,6 +48,7 @@ tags:
  • text 中的所有单词之间都由 单个空格字符 分隔
  • 1 <= first.length, second.length <= 10
  • first 和 second 由小写英文字母组成
  • +
  • text 不包含任何前缀或尾随空格。
  • diff --git a/solution/1000-1099/1078.Occurrences After Bigram/README_EN.md b/solution/1000-1099/1078.Occurrences After Bigram/README_EN.md index 29a645c50110a..68ca81d7732dd 100644 --- a/solution/1000-1099/1078.Occurrences After Bigram/README_EN.md +++ b/solution/1000-1099/1078.Occurrences After Bigram/README_EN.md @@ -36,9 +36,10 @@ tags: diff --git a/solution/1100-1199/1137.N-th Tribonacci Number/README_EN.md b/solution/1100-1199/1137.N-th Tribonacci Number/README_EN.md index 292e565c0e86d..794b421babefb 100644 --- a/solution/1100-1199/1137.N-th Tribonacci Number/README_EN.md +++ b/solution/1100-1199/1137.N-th Tribonacci Number/README_EN.md @@ -27,43 +27,29 @@ tags:

    Given n, return the value of Tn.

     

    -

    Example 1:

    -
     Input: n = 4
    -
     Output: 4
    -
     Explanation:
    -
     T_3 = 0 + 1 + 1 = 2
    -
     T_4 = 1 + 1 + 2 = 4
    -
     

    Example 2:

    -
     Input: n = 25
    -
     Output: 1389537
    -
     

     

    -

    Constraints:

    diff --git a/solution/1100-1199/1160.Find Words That Can Be Formed by Characters/README.md b/solution/1100-1199/1160.Find Words That Can Be Formed by Characters/README.md index 5f2b6c1281388..6b9897e53caa4 100644 --- a/solution/1100-1199/1160.Find Words That Can Be Formed by Characters/README.md +++ b/solution/1100-1199/1160.Find Words That Can Be Formed by Characters/README.md @@ -8,6 +8,7 @@ tags: - 数组 - 哈希表 - 字符串 + - 计数 --- diff --git a/solution/1100-1199/1160.Find Words That Can Be Formed by Characters/README_EN.md b/solution/1100-1199/1160.Find Words That Can Be Formed by Characters/README_EN.md index bc16f804f49ed..31be1570c7123 100644 --- a/solution/1100-1199/1160.Find Words That Can Be Formed by Characters/README_EN.md +++ b/solution/1100-1199/1160.Find Words That Can Be Formed by Characters/README_EN.md @@ -8,6 +8,7 @@ tags: - Array - Hash Table - String + - Counting --- diff --git a/solution/1200-1299/1215.Stepping Numbers/README.md b/solution/1200-1299/1215.Stepping Numbers/README.md index b074b3d0f53ff..2f81ebdf97269 100644 --- a/solution/1200-1299/1215.Stepping Numbers/README.md +++ b/solution/1200-1299/1215.Stepping Numbers/README.md @@ -6,6 +6,7 @@ rating: 1674 source: 第 10 场双周赛 Q3 tags: - 广度优先搜索 + - 数学 - 回溯 --- @@ -19,26 +20,34 @@ tags: -

    如果一个整数上的每一位数字与其相邻位上的数字的绝对差都是 1,那么这个数就是一个「步进数」。

    +

    如果一个整数上的每一位数字与其相邻位上的数字的绝对差都是 1,那么这个数就是一个「步进数」。

    -

    例如,321 是一个步进数,而 421 不是。

    +

    例如,321 是一个 步进数,而 421 不是。

    -

    给你两个整数,low 和 high,请你找出在 [low, high] 范围内的所有步进数,并返回 排序后 的结果。

    +

    给你两个整数,low 和 high,请你找出在 [low, high] 范围内的所有 步进数,并返回 排序后 的结果。

     

    -

    示例:

    +

    示例 1:

    -
    输入:low = 0, high = 21
    +
    +输入:low = 0, high = 21
     输出:[0,1,2,3,4,5,6,7,8,9,10,12,21]
     
    +

    示例 2:

    + +
    +输入:low = 10, high = 15
    +输出:[10,12]
    +
    +

     

    提示:

    diff --git a/solution/1200-1299/1215.Stepping Numbers/README_EN.md b/solution/1200-1299/1215.Stepping Numbers/README_EN.md index 0480a67192d7a..1129017a57cae 100644 --- a/solution/1200-1299/1215.Stepping Numbers/README_EN.md +++ b/solution/1200-1299/1215.Stepping Numbers/README_EN.md @@ -6,6 +6,7 @@ rating: 1674 source: Biweekly Contest 10 Q3 tags: - Breadth-First Search + - Math - Backtracking --- diff --git a/solution/1300-1399/1370.Increasing Decreasing String/README.md b/solution/1300-1399/1370.Increasing Decreasing String/README.md index 128bd0ab3e99a..14a7ce907e068 100644 --- a/solution/1300-1399/1370.Increasing Decreasing String/README.md +++ b/solution/1300-1399/1370.Increasing Decreasing String/README.md @@ -24,10 +24,10 @@ tags:
    1. s 中选出 最小 的字符,将它 接在 结果字符串的后面。
    2. -
    3. s 剩余字符中选出 最小 的字符,且该字符比上一个添加的字符大,将它 接在 结果字符串后面。
    4. +
    5. s 剩余字符中选出比上一个添加字符更大的 最小 字符,将它 接在 结果字符串后面。
    6. 重复步骤 2 ,直到你没法从 s 中选择字符。
    7. s 中选出 最大 的字符,将它 接在 结果字符串的后面。
    8. -
    9. s 剩余字符中选出 最大 的字符,且该字符比上一个添加的字符小,将它 接在 结果字符串后面。
    10. +
    11. s 剩余字符中选出比上一个添加字符更小的 最大 字符,将它 接在 结果字符串后面。
    12. 重复步骤 5 ,直到你没法从 s 中选择字符。
    13. 重复步骤 1 到 6 ,直到 s 中所有字符都已经被选过。
    diff --git a/solution/1400-1499/1431.Kids With the Greatest Number of Candies/README.md b/solution/1400-1499/1431.Kids With the Greatest Number of Candies/README.md index 4a192a718f0a7..0635e71b80ce6 100644 --- a/solution/1400-1499/1431.Kids With the Greatest Number of Candies/README.md +++ b/solution/1400-1499/1431.Kids With the Greatest Number of Candies/README.md @@ -35,7 +35,7 @@ tags: 孩子 1,将有 2 + 3 = 5 个糖果,是孩子中最多的。 孩子 2,将有 3 + 3 = 6 个糖果,是孩子中最多的。 孩子 3,将有 5 + 3 = 8 个糖果,是孩子中最多的。 -孩子 4,将有 1 + 3 = 4 个糖果,是孩子中最多的。 +孩子 4,将有 1 + 3 = 4 个糖果,不是孩子中最多的。 孩子 5,将有 3 + 3 = 6 个糖果,是孩子中最多的。

    示例 2:

    diff --git a/solution/1600-1699/1684.Count the Number of Consistent Strings/README.md b/solution/1600-1699/1684.Count the Number of Consistent Strings/README.md index 866df5d11f411..c0a6aebff87a2 100644 --- a/solution/1600-1699/1684.Count the Number of Consistent Strings/README.md +++ b/solution/1600-1699/1684.Count the Number of Consistent Strings/README.md @@ -9,6 +9,7 @@ tags: - 数组 - 哈希表 - 字符串 + - 计数 --- diff --git a/solution/1600-1699/1684.Count the Number of Consistent Strings/README_EN.md b/solution/1600-1699/1684.Count the Number of Consistent Strings/README_EN.md index bfd62009bf747..68ead74ee66be 100644 --- a/solution/1600-1699/1684.Count the Number of Consistent Strings/README_EN.md +++ b/solution/1600-1699/1684.Count the Number of Consistent Strings/README_EN.md @@ -9,6 +9,7 @@ tags: - Array - Hash Table - String + - Counting --- diff --git a/solution/1800-1899/1822.Sign of the Product of an Array/README_EN.md b/solution/1800-1899/1822.Sign of the Product of an Array/README_EN.md index 37522697c5fc4..35a3fcf6183e9 100644 --- a/solution/1800-1899/1822.Sign of the Product of an Array/README_EN.md +++ b/solution/1800-1899/1822.Sign of the Product of an Array/README_EN.md @@ -19,7 +19,7 @@ tags: -

    There is a function signFunc(x) that returns:

    +

    Implement a function signFunc(x) that returns:

    +

     

    +

    Note: This question is the same as 2615: Sum of Distances.

    + ## Solutions diff --git a/solution/2400-2499/2456.Most Popular Video Creator/README_EN.md b/solution/2400-2499/2456.Most Popular Video Creator/README_EN.md index 9c04d49793fdd..555644f9d94a1 100644 --- a/solution/2400-2499/2456.Most Popular Video Creator/README_EN.md +++ b/solution/2400-2499/2456.Most Popular Video Creator/README_EN.md @@ -22,7 +22,7 @@ tags: -

    You are given two string arrays creators and ids, and an integer array views, all of length n. The ith video on a platform was created by creator[i], has an id of ids[i], and has views[i] views.

    +

    You are given two string arrays creators and ids, and an integer array views, all of length n. The ith video on a platform was created by creators[i], has an id of ids[i], and has views[i] views.

    The popularity of a creator is the sum of the number of views on all of the creator's videos. Find the creator with the highest popularity and the id of their most viewed video.

    @@ -31,32 +31,40 @@ tags:
  • If multiple videos have the highest view count for a creator, find the lexicographically smallest id.
  • -

    Return a 2D array of strings answer where answer[i] = [creatori, idi] means that creatori has the highest popularity and idi is the id of their most popular video. The answer can be returned in any order.

    +

    Note: It is possible for different videos to have the same id, meaning that ids do not uniquely identify a video. For example, two videos with the same ID are considered as distinct videos with their own viewcount.

    + +

    Return a 2D array of strings answer where answer[i] = [creatorsi, idi] means that creatorsi has the highest popularity and idi is the id of their most popular video. The answer can be returned in any order.

     

    Example 1:

    -
    -Input: creators = ["alice","bob","alice","chris"], ids = ["one","two","three","four"], views = [5,10,5,4]
    -Output: [["alice","one"],["bob","two"]]
    -Explanation:
    -The popularity of alice is 5 + 5 = 10.
    -The popularity of bob is 10.
    -The popularity of chris is 4.
    -alice and bob are the most popular creators.
    -For bob, the video with the highest view count is "two".
    -For alice, the videos with the highest view count are "one" and "three". Since "one" is lexicographically smaller than "three", it is included in the answer.
    -
    +
    +

    Input: creators = ["alice","bob","alice","chris"], ids = ["one","two","three","four"], views = [5,10,5,4]

    + +

    Output: [["alice","one"],["bob","two"]]

    + +

    Explanation:

    + +

    The popularity of alice is 5 + 5 = 10.
    +The popularity of bob is 10.
    +The popularity of chris is 4.
    +alice and bob are the most popular creators.
    +For bob, the video with the highest view count is "two".
    +For alice, the videos with the highest view count are "one" and "three". Since "one" is lexicographically smaller than "three", it is included in the answer.

    +

    Example 2:

    -
    -Input: creators = ["alice","alice","alice"], ids = ["a","b","c"], views = [1,2,2]
    -Output: [["alice","b"]]
    -Explanation:
    -The videos with id "b" and "c" have the highest view count.
    -Since "b" is lexicographically smaller than "c", it is included in the answer.
    -
    +
    +

    Input: creators = ["alice","alice","alice"], ids = ["a","b","c"], views = [1,2,2]

    + +

    Output: [["alice","b"]]

    + +

    Explanation:

    + +

    The videos with id "b" and "c" have the highest view count.
    +Since "b" is lexicographically smaller than "c", it is included in the answer.

    +

     

    Constraints:

    diff --git a/solution/2500-2599/2506.Count Pairs Of Similar Strings/README.md b/solution/2500-2599/2506.Count Pairs Of Similar Strings/README.md index cd17af9badb85..aa9e74b194079 100644 --- a/solution/2500-2599/2506.Count Pairs Of Similar Strings/README.md +++ b/solution/2500-2599/2506.Count Pairs Of Similar Strings/README.md @@ -9,6 +9,7 @@ tags: - 数组 - 哈希表 - 字符串 + - 计数 --- diff --git a/solution/2500-2599/2506.Count Pairs Of Similar Strings/README_EN.md b/solution/2500-2599/2506.Count Pairs Of Similar Strings/README_EN.md index 4fd22e5926292..3b483b5ff297d 100644 --- a/solution/2500-2599/2506.Count Pairs Of Similar Strings/README_EN.md +++ b/solution/2500-2599/2506.Count Pairs Of Similar Strings/README_EN.md @@ -9,6 +9,7 @@ tags: - Array - Hash Table - String + - Counting --- diff --git a/solution/2500-2599/2576.Find the Maximum Number of Marked Indices/README_EN.md b/solution/2500-2599/2576.Find the Maximum Number of Marked Indices/README_EN.md index ff328aff8910e..d18fe806c6420 100644 --- a/solution/2500-2599/2576.Find the Maximum Number of Marked Indices/README_EN.md +++ b/solution/2500-2599/2576.Find the Maximum Number of Marked Indices/README_EN.md @@ -70,7 +70,7 @@ Since there is no other operation, the answer is 4.

     

    -